Ajax,
Thanks so much for the tips. Well, that solution worked just fine at first. But then, I added a few more lines of code to export another query to the same workbook, and I'm getting the problem all over again. Same error message, on the same line, every other time I run the code.
Any suggestions on what I can do now? I've pasted the code below, with the added lines in bold.
(FYI, xlApp.Close didn't work- I used xlApp.Quit instead. Is that correct?)
Code:
Private Sub Command155_Click()
Dim xlApp As Object
Dim ShortBookName As String
Dim FullBookName As String
Dim BookPath As String
Set xlApp = CreateObject("Excel.Application")
DoCmd.OutputTo acOutputQuery, "qryExportPerpQuestions", acFormatXLSX, , True
FullBookName = xlApp.ActiveWorkbook.FullName
Debug.Print FullBookName
ShortBookName = Right(FullBookName, Len(FullBookName) - InStrRev(FullBookName, "\"))
Debug.Print ShortBookName
BookPath = xlApp.ActiveWorkbook.Path
Debug.Print BookPath
DoCmd.OutputTo acOutputQuery, "qryExportMeetingInfo", acFormatXLSX, BookPath & "\Dummy Workbook-" & ShortBookName, True
xlApp.ActiveSheet.Move Before:=Workbooks(ShortBookName).Sheets(1)
xlApp.ActiveWorkbook.Save
xlApp.Quit
Set xlApp = Nothing
End Sub