I have the following code which I found online in a standalone sub procedure, just to test it out for future use.
It's in Access 2010, in case that makes a difference.
The code runs as far as opening Excel and producing Msgbox "5", then skips straight to the end.
No error message is displayed, but it's not saving the file and it's ignoring the rest of the code and leaving an Excel process hanging.
I figure there has to be something simple I'm missing.
I've debugged to confirm that strMasterBook is correctly set.
I've tried hard coding in the filepath, in case the variable was causing the problem.
Any ideas?
It's in Access 2010, in case that makes a difference.
Code:
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim strMasterBook as string
strMasterBook = "P:\QE\New Model Activity\Automobile\PQS\IQS project\PQS data\_2022\AllData_2022.xlsm"
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWB = xlApp.Workbooks.Add
MsgBox "5"
xlWB.SaveAs strMasterBook
MsgBox "6"
xlWB.Close SaveChanges:=False
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
The code runs as far as opening Excel and producing Msgbox "5", then skips straight to the end.
No error message is displayed, but it's not saving the file and it's ignoring the rest of the code and leaving an Excel process hanging.
I figure there has to be something simple I'm missing.
I've debugged to confirm that strMasterBook is correctly set.
I've tried hard coding in the filepath, in case the variable was causing the problem.
Any ideas?