This is directly related to the following two posts:
How do I export 2 queries to a single worksheet in excel from access
Saving a custom export from an Access 2007 script
I am using Access 2010, and I have created a command button on a form with the following VBA in its Click event. The VBA allows me to export multiple queries, into different worksheets, within the same Excel file:
VBA #1: This exports multiple queries into one Excel file
Private Sub CommandBtn_Click()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Query1", "test1.xlsx", True, "NameofWorksheet"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Query2", "test1.xlsx", True, "NameofSecondWorksheet"
End Sub
Edit(4/7/2014: 11:26 AM): Clarified what I want below.
Desire
I want to add the following feature to my command button's Click event: A "Save As" dialog window that prompts the user to choose where to save the newly created Excel file (test1.xlsx).
Challenges:
I do not know what VBA code would be appropriate to use for doing so. I ran into the FileDialog(msoFileDialogSaveAs) option when doing my research on this. However, I have not been able to successfully use it to produce what I want.