I have been trying to get DoCmd.TransferSpreadsheet to work in my vba code. and it refuses to work how I need it to. Maybe my syntax is wrong, or something, but I can't figure it out.
I have
Get_Temp_Data_fun("File_Path") returns the excel sheet I am exporting to w/ full path. i.e. "C:\Documen... ...Test Data.xls"
Get_Temp_Data_fun("Sheet_Name") returns the name of the spreadsheet I want the sheet to be transfered as (what it should be in the excel file) i.e. "Test_Sheet"
"Concatenated" is the name of the query I am trying to send to excel.
I saw doing the File_Name!Sheet_Name somewhere, but can't make it work. It returns a Run-time error ‘424: Object Required. Using Just File_Name works fine, however, I need to make it output with a different sheet name everytime, and I will not know what the sheet name is before hand (the user is selecting a different sheet to use every time)
Any thoughts on what I should change to get this to work correctly?
Thanks for any help.
I have
Code:
Function Copy_to_excel
File_Name = Get_Temp_Data_fn("File_Path")
Sheet_Name = Get_Temp_Data_fun("Sheet_Name")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Concatenated", File_Name!Sheet_Name, True, ""
End Function
Get_Temp_Data_fun("File_Path") returns the excel sheet I am exporting to w/ full path. i.e. "C:\Documen... ...Test Data.xls"
Get_Temp_Data_fun("Sheet_Name") returns the name of the spreadsheet I want the sheet to be transfered as (what it should be in the excel file) i.e. "Test_Sheet"
"Concatenated" is the name of the query I am trying to send to excel.
I saw doing the File_Name!Sheet_Name somewhere, but can't make it work. It returns a Run-time error ‘424: Object Required. Using Just File_Name works fine, however, I need to make it output with a different sheet name everytime, and I will not know what the sheet name is before hand (the user is selecting a different sheet to use every time)
Any thoughts on what I should change to get this to work correctly?
Thanks for any help.