The code below is run from a command button on a form. It opens a query parameter form that I use to select the begin and end dates. The query results go to an excel spreadsheet. A second spreadsheet opens and links to the fields returned in the first spreadsheet. All of this works fine. However, when I try to exit Access it simply hangs and I have to go to task manager to kill the process. I think that I am not cleaning up as I should after the two spreadsheets are open. Suggestions?
Code:
Private Sub ReportToExcel_Click()
On Error GoTo Err_ReportToExcel_Click
DoCmd.OutputTo ObjectType:=acOutputReport, _
ObjectName:="rptTimeTOExcel", _
OutputFormat:=acFormatXLS, _
OutputFile:="\\bigguy\users\Dom_F\Access\TimeAndBilling\TestData.xls", _
AutoStart:=True
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "\\bigguy\users\Dom_F\Access\TimeAndBilling\time sheet03052011.xls", True, False
Set xlApp = Nothing
Exit_ReportToExcel_Click:
Exit Sub
Err_ReportToExcel_Click:
MsgBox Err.Description
Resume Exit_ReportToExcel_Click
End Sub