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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Excel Problem

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
I have a module which opens multiple Excel workbooks and then reads data from different sheets within the workbook, then transfers the data to a table.
I'm using :-


Set xlobject = CreateObject("Excel.Application")
'this is where we open the Excel spreadsheet
'
xlobject.Application.Workbooks.Open ExcelName
'specify the first sheet
StrExcelTab = "Trans-Dir"
Set xlsheet = xlobject.Application.activeworkbook.sheets(StrExcelTab)


:- to open the workbooks

and :-

DoCmd.SetWarnings False
xlobject.Application.Quit
Set xlobject = Nothing
DoCmd.SetWarnings True

:- to close the workbook

but the Excel program is still left running when the code has executed. Even worse there is a instance of Excel for every call to open a workbook ( 24 in test mode ).

Am I missing some code to close Excel completley after each pass through the workbook ???

Steady ... [thumbsup2]

 
Consider trying something like this:


Public Function doExcel(fileNm As String) As String

Dim wbk As Workbook
Set wbk = Excel.Workbooks.Open(fileNm, , True)
'Manipulate Worksheet here
'
wbk.Close
Set wbk = Nothing

End Function


You do need to make certain that you have the Excel objects referenced in your reference library for that database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top