azizrasul
Well-known Member
- Joined
- Jul 7, 2003
- Messages
- 1,294
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
I have the following snippet of code in Access: -
When I try to open the xls file, I only see the header of the application. I can resolve the problem by ending the application in ther task manager. How do I amend the code so that Excel leaves memory automatically.
Just realised I have placed this in the wrong section. My apologies.
Code:
strFilename = "U:\Reports\" & Left(strTrustName, 49)
DoCmd.TransferSpreadsheet acExport, 8, "qryAllTrustsSummarisedReport", strFilename, True, ""
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
Workbooks.Open Filename:="U:\Reports\" & strTrustName & ".xls", ReadOnly:=False
Worksheets(1).Name = "Cost Savings Report on Food"
objExcelApp.DisplayAlerts = False
Worksheets(1).SaveAs strFilename
objExcelApp.Quit
Set objExcelApp = Nothing
When I try to open the xls file, I only see the header of the application. I can resolve the problem by ending the application in ther task manager. How do I amend the code so that Excel leaves memory automatically.
Just realised I have placed this in the wrong section. My apologies.