Stang70Fastback
Registered User.
- Local time
- Today, 01:30
- Joined
- Dec 24, 2012
- Messages
- 132
Hey guys. I have a question. I need Access to open an Excel file prior to pulling information from it, because the Excel file itself only updates when it is opened. I was able to achieve this with the code below:
This works fine if NO Excel window is already open, but if the user happens to have some file open in Excel already, my code doesn't seem to work right. The file does not open in a hidden window. Instead, it opens in the window already open, and additionally, the file is not closed afterward, which leaves the user wondering where the hell this random file came from, and they have to close it. Does anyone know how I can resolve this issue? I need this Excel file to open, but I want it to be completely hidden from the user.
'Opens a hidden Excel window.
Dim app As New Excel.Application
app.Visible = False
Dim book As Excel.Workbook
Set book = app.Workbooks.Open("S:\Operations\Assistant\Databases\BUSES.xlsx")
...blah, blah, blah, doing stuff...
'Closes the Excel window.
book.Close SaveChanges:=False
app.Quit
Set app = Nothing
This works fine if NO Excel window is already open, but if the user happens to have some file open in Excel already, my code doesn't seem to work right. The file does not open in a hidden window. Instead, it opens in the window already open, and additionally, the file is not closed afterward, which leaves the user wondering where the hell this random file came from, and they have to close it. Does anyone know how I can resolve this issue? I need this Excel file to open, but I want it to be completely hidden from the user.