Hi all, hopefully this is an easy question, seems like it should be but I don't know the answer!
I have some Access code which opens an Excel doc (referenced in a text box on a form) and imports the document into a new table. Easy enough. I don't need or want to see the Excel document being opened, I don't need it opened for any reason other than to import it into the Access table. I need to actually open it versus simply importing it because there's a goofy Excel error message due to formatting and I need to set DisplayAlerts = False for it to import. If I do not have an instance of Excel open on my computer prior to running the code, this process is seamless and "invisible" to me. However, if I have a workbook open and then run the code, I "see" the file I'm importing and then it does not close when the code completes. Then, within Excel I have a message box stating that the file is now available, do I want to open it or read only? I can close the file manually, but I do not want my users to be confused or irritated by this unnecessary step. Can someone point out how I'd have to modify my code to achieve this? Sorry for the wordy description!
Kelly
I have some Access code which opens an Excel doc (referenced in a text box on a form) and imports the document into a new table. Easy enough. I don't need or want to see the Excel document being opened, I don't need it opened for any reason other than to import it into the Access table. I need to actually open it versus simply importing it because there's a goofy Excel error message due to formatting and I need to set DisplayAlerts = False for it to import. If I do not have an instance of Excel open on my computer prior to running the code, this process is seamless and "invisible" to me. However, if I have a workbook open and then run the code, I "see" the file I'm importing and then it does not close when the code completes. Then, within Excel I have a message box stating that the file is now available, do I want to open it or read only? I can close the file manually, but I do not want my users to be confused or irritated by this unnecessary step. Can someone point out how I'd have to modify my code to achieve this? Sorry for the wordy description!
Code:
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Set objXL = New Excel.Application
'Turn off excel warnings
objXL.DisplayAlerts = False
'Import JIT file
DoCmd.TransferSpreadsheet acImport, , "tmpJIT", txtJITReportFile, True
'Close the JIT file
objWkb.Close
objXL.Quit
Set objXL = Nothing
Set objWkb = Nothing
Kelly