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: 

Macro Help: Macro to Open file from Excel BOM

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ablountE9KSN
216 Views, 4 Replies

Macro Help: Macro to Open file from Excel BOM

So the intended purpose of the macro is to select the file name from the excel BOM - and then run the macro - the macro would then open the file in inventor. The code is running in excel vba from my exported BOM. 

 

This is my code

 

Sub OpenDrawing()
    Dim FileLocation As String
    FileLocation = Range("C4")

    Dim FileName As String
    FileName = ActiveCell.Value

 

    Dim FullFileDirectory As String
    FullFileDirectory = FileLocation & "\" & FileName

 

    Dim InvApp As Inventor.Application
    Set InvApp = CreateObject("Inventor.Application")
    Dim Doc As Inventor.Document
    Set Doc = InvApp.Documents.Open(FullFileDirectory, True)

 

End Sub

 

Im getting an error on the "Set Doc" line "Run time error '5: Invalid Call Procedure or argument"

 

I'm new to vba so any help is appreciated 

4 REPLIES 4
Message 2 of 5
A.Acheson
in reply to: ablountE9KSN

Hi @ablountE9KSN 

Can you check you fullfilepath has an extension .ipt or .iam and or copy and paste to windows and launch to verify?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5
ablountE9KSN
in reply to: ablountE9KSN

that was it - I ended up adding a file extension to the FullFileDirectory string and it worked perfectly. 

Message 4 of 5
m_scottW4DSR
in reply to: ablountE9KSN

@A.Acheson 

I am running this code and it executes without error.  But nothing is happening with the inventor application. I have run with and without an open inventor session.  Any idea of the issue?  I'm guessing something not configured properly with inventor?

 

Thanks!

Message 5 of 5
m_scottW4DSR
in reply to: m_scottW4DSR

Added

oInvApp.Visible = True

and all is well.

 

Not sure why 

Set oDoc = oInvApp.Documents.Open(sfilename, True)

didn't take care of it

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report