Hi,
I am trying to write a bit of code that will create an export file in a predetermined location, such as the desktop. I don't want the user to have to choose. I just want them to be able to click a command button and export all the tables in my DB to different sheets of the same excel workbook. Currently I have this:
Code:
Private Sub Command23_Click()
strPath = "C:\Users\John\Desktop\Exportfile"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Table1", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Table2", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Table3", strPath
MsgBox "The files have been successfully saved to: 'C:\Users\John\Desktop'", vbOKOnly, ""
End Sub
The problem is, I don't know what the user's login will be, and there may be several different users. I could write a variable, but I'm not sure how, and I'm worried that the variable language may not be universal enough to work across different versions of windows. One idea I had was to find a way to identify the filepath of the open Access application and use the same filepath for the export; that way it doesn't matter because wherever the user has stored the DB, the export will always be right next to it. Does anyone know if that is possible?