I have a routine that opens an Excel 2003 workbook, retrieve some custom properties and loades to memory for use, then closes the Excel workbook. When there is only one workbook to check there is not a problem because when the access appliation is closed it kills the specific Excel process.
The problem is that there may be multiple Excel files that my Access application needs to process one after the other without closing. I found some information that said, if I open the Excel file with its visibility property false then this happens, so I changed it, making it visible and it still leaves the process running after closing the workbook. Does anyone know how to get around this?
I thought about looping through the processes and killing all Excel.exe processes but the user may have workbooks open that are unrelated and I don't want to kill those processes, only the one specifically opened by my Access mdb. Help! See code below...
Note: some variables are defined as Public and populated else were. EPSET is the Excel workbook. I have also tried xl.quit
Function ExtractFile(ByVal workingFolder As String)
...
'Compare the version of the EPSET to the verson of the database
xlV$ = GetEPSETV(SourceFile$) 'calls the problematic routine
If UCase(xlV$) <> UCase(SWV$) Then
Err.Raise Number:=vbObjectError + 3000
End If
...
end function
Function GetEPSETV(SourceFile$)
'Created by: Steve Ellertson
'Created: 1/4/12
'Comments: This function gets the EPSET version and returns it to the calling
'function.
'_________________________________________________________________
Dim sfullpath$
Set xl = CreateObject("Excel.Application")
sfullpath$ = wrkdir$ & SourceFile$
GetEPSETV = Empty
With xl
.Workbooks.Open (sfullpath$)
.Visible = True
GetEPSETV = ActiveWorkbook.CustomDocumentProperties.Item("Version").Value
End With
Set xl = Nothing
Excel.Application.Quit 'This is the problem statement
End Function
S J E
If I am not learning, then I am coasting, if I am coasting I must be going down hill.
The problem is that there may be multiple Excel files that my Access application needs to process one after the other without closing. I found some information that said, if I open the Excel file with its visibility property false then this happens, so I changed it, making it visible and it still leaves the process running after closing the workbook. Does anyone know how to get around this?
I thought about looping through the processes and killing all Excel.exe processes but the user may have workbooks open that are unrelated and I don't want to kill those processes, only the one specifically opened by my Access mdb. Help! See code below...
Note: some variables are defined as Public and populated else were. EPSET is the Excel workbook. I have also tried xl.quit
Function ExtractFile(ByVal workingFolder As String)
...
'Compare the version of the EPSET to the verson of the database
xlV$ = GetEPSETV(SourceFile$) 'calls the problematic routine
If UCase(xlV$) <> UCase(SWV$) Then
Err.Raise Number:=vbObjectError + 3000
End If
...
end function
Function GetEPSETV(SourceFile$)
'Created by: Steve Ellertson
'Created: 1/4/12
'Comments: This function gets the EPSET version and returns it to the calling
'function.
'_________________________________________________________________
Dim sfullpath$
Set xl = CreateObject("Excel.Application")
sfullpath$ = wrkdir$ & SourceFile$
GetEPSETV = Empty
With xl
.Workbooks.Open (sfullpath$)
.Visible = True
GetEPSETV = ActiveWorkbook.CustomDocumentProperties.Item("Version").Value
End With
Set xl = Nothing
Excel.Application.Quit 'This is the problem statement
End Function
S J E
If I am not learning, then I am coasting, if I am coasting I must be going down hill.