Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2004

Tip: Looking for answers? Try searching our database.

Excel Automation from Access - releasing instance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Cobden - 19 Dec 2004 22:31 GMT
I have a problem with the following code, which leaves an instance of Excel
visible in Task Manager. By a process of elimination I have got it down to
the fact that something in the DoCmd.Transfer Spreadsheet line is holding on
to an Excel reference somewhere - can anybody assist (if I comment this line
out, the instance is released, and not visible in Task Manager). Private Sub
btnLoadData_Click()Dim xlApp2 As ObjectDim xlBook As WorkbookDim xlSheet As
WorksheetDim strFilename as stringSet strfilename = "c:\test.xls"Set xlApp2
= CreateObject("Excel.Application")xlApp2.Visible = TrueSelect Case
Me.Data_File_From        Case "West Herts"            xlApp2.Workbooks.Open
FileName:=strFileName,
Password:="barbados"        Case "Luton"            xlApp2.Workbooks.Open
FileName:=strFileName        Case "Stoke Mand"
xlApp2.Workbooks.Open FileName:=strFileName,
Password:="amersham"        Case "South Bucks"
xlApp2.Workbooks.Open FileName:=strFileName,
Password:="amersham"        Case "South Bucks Susp"
xlApp2.Workbooks.Open FileName:=strFileName,
Password:="amersham"End Select        DoCmd.TransferSpreadsheet , ,
strImportTableName, strFileName, True        xlApp2.Workbooks.ClosefCloseApp
("XLMain")        Set xlBook = Nothing        xlApp2.QuitSet xlApp2 =
Nothing End Sub  Function fCloseApp(lpClassName As String) As Boolean Dim
lngRet As Long, hWnd As Long, pID As Long     hWnd =
apiFindWindow(lpClassName, vbNullString)    If (hWnd) Then        lngRet =
apiPostMessage(hWnd, WM_CLOSE, 0, ByVal 0&)        Call
apiGetWindowThreadProcessId(hWnd, pID)        Call
apiWaitForSingleObject(pID, INFINITE)        fCloseApp = Not
(apiIsWindow(hWnd) = 0)    End IfEnd Function Thanks Gary
Eric Schittlipz - 19 Dec 2004 23:33 GMT
>I have a problem with the following code, which leaves an instance of Excel
> visible in Task Manager. By a process of elimination I have got it down to
[quoted text clipped - 30 lines]
> apiWaitForSingleObject(pID, INFINITE)        fCloseApp = Not
> (apiIsWindow(hWnd) = 0)    End IfEnd Function Thanks Gary

Did my previous answer to this not show up?  You received more than one
response which you seem to have ignore and started a new post.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.