Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Opening Excel using a "Public Function"

1 REPLY 1
Reply
Message 1 of 2
isocam
348 Views, 1 Reply

Opening Excel using a "Public Function"

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

1 REPLY 1
Message 2 of 2
petercharles
in reply to: 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



 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report