Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel instance remains open 1

Status
Not open for further replies.

Orion45

IS-IT--Management
Feb 6, 2002
155
US
I am currently using a form in Access (Office '03) to allow the user to import data from various Excel files. This is done using the TransferSpreadsheet method. However, after the data has been migrated an instance of Excel remains open. This becomes problematic when the user tries to use Excel for another purpose. Does anyone know of a way to completely close Excel using VBA? My code is currently as follows:
Code:
Set xl = New Excel.Application    
xl.Dialogs(xlDialogFindFile).Show
strPath = xl.ActiveWorkbook.FullName
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTable, strPath, -1
xl.Quit
Set xl = Nothing

Thanks!
 
Hm - since you are using a2k3, why not use application filediaolog in stead? There's a sample in the help files, just remember to set a reference to the Microsoft Office object library (in VBE - Tools | References)

Or use this Call the standard Windows File Open/Save dialog box wrapper for the GetOpenFileName API.

Using either of these approaches, there's no need to automate Excel at all.

Roy-Vidar
 
That worked great (first approach). Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top