Vb.Net Problem - Run Inventor VBA Macro

Vb.Net Problem - Run Inventor VBA Macro

isocam
Collaborator Collaborator
1,265 Views
16 Replies
Message 1 of 17

Vb.Net Problem - Run Inventor VBA Macro

isocam
Collaborator
Collaborator

Can somebody please help?

 

I have attached a Vb.Net form and a module (I have changed the file name extension from vb to txt). 

 

I cannot get it to work and I do not know what I am doing wrong!

 

I am trying to run a Inventor VBA macro called "OnSave" in "Module02" of the Default.ivb

 

The macro is located in the folder: "C:\Users\Public\Documents\Autodesk\Inventor 2019\Macros"

 

Can anybody tell me what is wrong with the program?

 

Many thanks in advance!!!

 

Darren

0 Likes
1,266 Views
16 Replies
Replies (16)
Message 2 of 17

bradeneuropeArthur
Mentor
Mentor

What do you try to achieve?

Do you wish a "on save" macro?

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 17

bradeneuropeArthur
Mentor
Mentor

try this:

Dim invVBA As InventorVBAMember
For Each pr In ThisApplication.VBAProjects

If pr.Name = "ApplicationProject" Then
MsgBox pr.Name

Dim invVBA As InventorVBAMember
invVBA = pr.InventorVBAComponents.Item("Module02").InventorVBAMembers("OnSave")
      
End If
Next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 17

isocam
Collaborator
Collaborator

 

When I run the exe file it then calls the macro "OnSave" in module02.

 

I know I can do this inside Inventor but I am trying to create an external "exe" file that runs the macro.

Is it possible to create a Vb.net program for me and I will pay you via PayPal?

 

Regards

 

Darren

0 Likes
Message 5 of 17

bradeneuropeArthur
Mentor
Mentor

 

could you make a screenshot of your vba projects

with the module expanded.

so I can see the exact names of the vba browser.

 

additional:

Can you exactly explain what you need for the external exe...

 

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 17

bradeneuropeArthur
Mentor
Mentor

You could also send me a private message with the programming details in it of course.

Than I can take a look if it is possible what you try/are willing to do.

I will here from you...

 

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 17

isocam
Collaborator
Collaborator

Hi,

I have attached a screenshot of the VBA project.

 

What I am trying to achieve is the following.

 

I have a program that listens to the "check in" folder in Vault. It waits to see if an Inventor document (iam, ipt, idw, drw) is saved. If it is saved I need a second program to run a VBA macro. For testing, all this macro needs to do is show a msgbox. I am having trouble creating the Vb.net program that runs the VBA program.

 

I just don't know what is wrong with the program. Can you please help????

 

Regards

 

Darren

0 Likes
Message 8 of 17

isocam
Collaborator
Collaborator

Brandon,

I need to run the VBA macro in "Default.ivb" simply because the VBA program is large and complex.

For test only, you could make a sub "OnSave" but put a msgbox saying "Hello". All I need is the Vb.net program to run this macro.

Regards

 

Darren

0 Likes
Message 9 of 17

bradeneuropeArthur
Mentor
Mentor

Hi,

 

I will see.

Questions:

  • in the Default.ivb
    there is a module called "Module02"
    with a member called "OnSave"

 

  • What inventor version do you have?
  • Would you be satisfied with a program that selects a partdocument?
  • do you only need it for part documents?

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 17

bradeneuropeArthur
Mentor
Mentor

I have something ready for you, but can you give me a partfullpath for testing with you?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 11 of 17

isocam
Collaborator
Collaborator

Brandon,

 

As a test, please use "C:\Test\Test.ipt"

 

Regards

 

Darren

0 Likes
Message 12 of 17

bradeneuropeArthur
Mentor
Mentor

Please try if it works...

push button on the form select file and see if it runs.

base on inventor 2018...

 

this is the source code.

Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
Imports Inventor

Public Class Form1
    Public Myinv As Inventor.Application
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Myinv = GetObject(, "Inventor.application")

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OpenFileDialog1.Filter = "Inventor Part Files (*.ipt)|*.ipt"

        OpenFileDialog1.ShowDialog()
        MsgBox(OpenFileDialog1.FileName)

        Dim filename As String
        filename = OpenFileDialog1.FileName

        Dim oDoc As PartDocument = Myinv.Documents.Open(filename, True)
        MsgBox(oDoc.FullFileName)
        Dim invVBA As InventorVBAMember

        Try
            invVBA = Myinv.VBAProjects.Item(1).InventorVBAComponents.Item("Module02").InventorVBAMembers("OnSave")

            invVBA.Execute()
        Catch ex As Exception

        End Try

    End Sub
End Class

Regards,

 

Arthur...……..

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 13 of 17

bradeneuropeArthur
Mentor
Mentor

additional remark :

 

Inventor must be running....

 

regards,

 

Arthur.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 14 of 17

isocam
Collaborator
Collaborator

MANY THANKS!!!!

Darren

0 Likes
Message 15 of 17

bradeneuropeArthur
Mentor
Mentor

it works?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 16 of 17

isocam
Collaborator
Collaborator

It works great!!!

 

Please can you send me a money request, via paypal to d.j.smith@aim.com and I will pay you for the source code.

 

Many thanks for your help, very much appreciated!!!!

 

It is now, nearly 11pm on Saturday over here, please do not worry if you do not hear from me until tomorrow.

 

Kindest Regards

 

Darren

 

 

 

0 Likes
Message 17 of 17

bradeneuropeArthur
Mentor
Mentor

same time for me or a bit later....

this is too easy to get payed for.

take it as a gift.

regards,

 

Arthur

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes