I am using transferspreadsheet to output a query to an excel spreadsheet. I then want that spreadsheet to open automatically.
If I code the filename in the call shell command it works fine, as in:
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\excel.exe ""C:\Documents and Settings\Desktop\Filename.xls""", 1)
However, the way the code works is that the transferspreadsheet outputs to a filename chosen by the user from an input box. I've been racking my brain for several hours trying to get the variable strMyFile inserted into the Call Shell command with no luck.
My first thought was to replace path and filename.xls with strMyFile but excel comes back and says can't find strMyFile.xls. strMyFile is supposed to be a variable containing the full path and filename.
How do I pass the information in strMyFile to the call shell command? It was so easy with the transferspreadsheet portion.
Code is below
Thank you.
If I code the filename in the call shell command it works fine, as in:
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\excel.exe ""C:\Documents and Settings\Desktop\Filename.xls""", 1)
However, the way the code works is that the transferspreadsheet outputs to a filename chosen by the user from an input box. I've been racking my brain for several hours trying to get the variable strMyFile inserted into the Call Shell command with no luck.
My first thought was to replace path and filename.xls with strMyFile but excel comes back and says can't find strMyFile.xls. strMyFile is supposed to be a variable containing the full path and filename.
How do I pass the information in strMyFile to the call shell command? It was so easy with the transferspreadsheet portion.
Code is below
Code:
strMyfile = InputBox("Enter File Name", "File Name")
strMyfile = "C:\Documents and Settings\Rael\Desktop\" & strMyfile
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryWorkoutExport", strMyfile
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\excel.exe ""strMyFile""", 1)
Thank you.