Can anybody help???
I have the following two Functions in a VBA macro. The CloseExcel function works OK, but the OpenExcel function does not work. Does anybody know waht I am doing wrong?
(Filename is the Excel Spreadsheet file with path)
Public Function OpenExcel(oXlworkBook, oXl)
Dim oXl As Object
Dim oXlWorkBook As Object
Dim oXLWorkSheet As Object
Set oXl = CreateObject("Excel.Application")
Set oXlWorkBook = oXl.Workbooks.Open(FileName)
Set oXLWorkSheet = oXlWorkBook.Sheets(1)
End Function
Public Function CloseExcel(oXlWorkBook, oXl)
Set oXlWorkBook = Nothing
oXl.Quit
Set oXl = Nothing
End Function
Many thanks in advance!!!!
IsoCAM
I don't know if this will help but to interact with Excel in a sub I've used -
Sub stuff()
....
....
....
Dim excel_app As Excel.Application
app2check = "Excel.Application"
If IsApplicationRunning(app2check) = True Then
Set excel_app = Excel.Application
Else
Set excel_app = CreateObject("Excel.Application")
End If
....
....
....
End Sub
Function IsApplicationRunning(ByVal sAppName) As Boolean
Dim oApp As Object
On Error Resume Next
Set oApp = GetObject(, sAppName)
If Not oApp Is Nothing Then
Set oApp = Nothing
IsApplicationRunning = True
End If
End Function