HI!
I have this code below that I have referenced in another thread but that thread was not trying to solve what I am trying to resolve in this thread.
The other thread is What I need to resolve is in this code below is that I am setting up to export a query to an excel template that is already formatted. In the FileCopy statement below I am copying the template to the variable where the query should be exported to. If by chance the user has already opened that spreadsheet and didn't close it and runs the process that will redo this export it gives an error "Run-time 70 Permission denied" because the user already has the file open. How can I capture the error for the FileCopy so that I can give the user a friendly msgbox to say "the file is already open, either close it or use it instead"? And then exit the Sub?
Sub GTINs_Already_Synched_Submitted_by_Vendor()
DoCmd.SetWarnings False
template_file = "\\msfs05.lowes.com\data1\share\MDCM_Reports\Product_Information\PI Item Setup Tracker\Templates\GTINs Already Synched Submitted by Vendor.xlsm" '
report_file = "C:\PI_Edgenet_Reports\GTINs Already Synched Submitted by Vendor.xlsm"
sheet_name = "GTINs Already Synched Submitte"
FileCopy template_file, report_file
DoCmd.TransferSpreadsheet acOutputQuery, 10, "qry_tbl_Vendor_Email_From_Edgenet_Synched_History", report_file, False, "Data1"
Export_Report_For_All
End Sub
Appreciate anyone's assistance!
Thanks,
CF
I have this code below that I have referenced in another thread but that thread was not trying to solve what I am trying to resolve in this thread.
The other thread is What I need to resolve is in this code below is that I am setting up to export a query to an excel template that is already formatted. In the FileCopy statement below I am copying the template to the variable where the query should be exported to. If by chance the user has already opened that spreadsheet and didn't close it and runs the process that will redo this export it gives an error "Run-time 70 Permission denied" because the user already has the file open. How can I capture the error for the FileCopy so that I can give the user a friendly msgbox to say "the file is already open, either close it or use it instead"? And then exit the Sub?
Sub GTINs_Already_Synched_Submitted_by_Vendor()
DoCmd.SetWarnings False
template_file = "\\msfs05.lowes.com\data1\share\MDCM_Reports\Product_Information\PI Item Setup Tracker\Templates\GTINs Already Synched Submitted by Vendor.xlsm" '
report_file = "C:\PI_Edgenet_Reports\GTINs Already Synched Submitted by Vendor.xlsm"
sheet_name = "GTINs Already Synched Submitte"
FileCopy template_file, report_file
DoCmd.TransferSpreadsheet acOutputQuery, 10, "qry_tbl_Vendor_Email_From_Edgenet_Synched_History", report_file, False, "Data1"
Export_Report_For_All
End Sub
Appreciate anyone's assistance!
Thanks,
CF