Subsequent to opening the file (and other Excel files) I'll be doing a number of vLookUps (in Excel). Once complete I'll want to close the Excel files. In test I've tried to close an Excel spreadsheet a number of ways but keep getting errors. This seems like it should be simple but I can't seem to close the file from my VBA. Any guidance would be appreciated.
Dim xlApp As Excel.Application
Dim xlWrksht As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
my_path = "C:\Documents and Settings\folder_x\My Documents\Test Shell Function.xls"
Set xlWrkBk = xlApp.Workbooks.Open(my_path)
Thanks... That's perfect for the open since I'll want to open Excel in the background (i.e. without True). I still however have a problem closing the Excel spreadsheet. I get an error message telling me that an object is required. I tried adding the path to the close event but I continue to get the same message.
If you don't close Excel in the same procedure as the one where you open it, the object variable xlApp must be accessible from both procedures (i.e. the one where Excel is open and the one where Excel is closed). The simplest way to achieve this is by declaring xlApp in the declaration section of a module (i.e. ouside a Sub or Function procedure), like this: