Message 1 of 3

Not applicable
04-19-2017
12:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I wrote a VBA Code and now wanted it to start after click on save, but Autodesk deaktivated the option for makros.
I wonder now if this code still works, because I cant see any resault and the vb.net is new for me... maybe code doesnt work anymore or I make some misstakes?
http://adndevblog.typepad.com/manufacturing/vladimir-ananyev/page/6/
Public Sub RunMacro_VBA() Dim m_inventorApp As Inventor.Application = Nothing ' Try to get an active instance of Inventor Try m_inventorApp = System.Runtime.InteropServices _ .Marshal.GetActiveObject("Inventor.Application") Catch ex As Exception End Try ' If not active, create a new Inventor session If m_inventorApp Is Nothing Then Dim inventorAppType As Type = System _ .Type.GetTypeFromProgID("Inventor.Application") m_inventorApp = System.Activator _ .CreateInstance(inventorAppType) End If Dim oP As Inventor.InventorVBAProject For Each oP In m_inventorApp.VBAProjects If oP.Name = "ApplicationProject" Then Dim oC As Inventor.InventorVBAComponent For Each oC In oP.InventorVBAComponents If oC.Name = "Module1" Then Dim oM As Inventor.InventorVBAMember For Each oM In oC.InventorVBAMembers If oM.Name = "MyFunction" Then oM.Execute() End If Next oM End If Next oC End If Next End Sub
I edited
Module1 = CreateView
MyFunktion = VBAToExecute
The Module "CreateView" is in "ApplicationProject" (Default.ivb).
Alternative I can translate the VBA to a VB.net, but it was hard enough to me to create the vba code. 😞
Solved! Go to Solution.