<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run Macro On Save in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3596542#M134774</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open the StandardAddInServer.vb with an Texteditor, scroll down to the end and replace the OnSave-Sub with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub m_applicationEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_applicationEvents.OnSaveDocument

            If BeforeOrAfter = EventTimingEnum.kBefore Then
                'Lets make sure that the active document is a part document
                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If

                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If

                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If


            End If

        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;EDIT: compiled dll attached (replace txt with dll)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2012 12:54:00 GMT</pubDate>
    <dc:creator>Ralf_Krieg</dc:creator>
    <dc:date>2012-08-27T12:54:00Z</dc:date>
    <item>
      <title>Run Macro On Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3595300#M134772</link>
      <description>&lt;P&gt;The attached addin works Ok except that it only accepts "ipt" files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody upgrade the addin and compile it so that it can accept "ipt", "iam" &amp;amp; "idw" files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 22:27:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3595300#M134772</guid>
      <dc:creator>isocam</dc:creator>
      <dc:date>2012-08-24T22:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro On Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3595992#M134773</link>
      <description>&lt;P&gt;For the people that do not have Visual Studios, perhaps you could explain what it is you're doing On Save. Perhaps it could be done via iLogic / API instead / Event Triggers instead?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Aug 2012 23:56:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3595992#M134773</guid>
      <dc:creator>MegaJerk</dc:creator>
      <dc:date>2012-08-26T23:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro On Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3596542#M134774</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open the StandardAddInServer.vb with an Texteditor, scroll down to the end and replace the OnSave-Sub with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub m_applicationEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_applicationEvents.OnSaveDocument

            If BeforeOrAfter = EventTimingEnum.kBefore Then
                'Lets make sure that the active document is a part document
                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If

                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If

                If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
                    Try
                        Dim invVBAProject As InventorVBAProject = m_inventorApplication.VBAProjects.Item(1)
                        Dim invModule As InventorVBAComponent = invVBAProject.InventorVBAComponents.Item("Module01")
                        Dim invSub As InventorVBAMember = invModule.InventorVBAMembers.Item("Main")
                        invSub.Execute()
                    Catch ex As Exception

                    End Try

                End If


            End If

        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;EDIT: compiled dll attached (replace txt with dll)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 12:54:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3596542#M134774</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2012-08-27T12:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro On Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3600878#M134775</link>
      <description>&lt;P&gt;I think&amp;nbsp;&lt;SPAN&gt;&lt;A id="link_1397595a9d1" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564136" target="_self"&gt;krieg&lt;/A&gt;'s code answers this question. If the code in each branch is same, I would suggest to combine all conditions, e.g.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;DocumentTypeEnum docType = m_inventorApplication.ActiveDocument.DocumentType&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If docType = DocumentTypeEnum.kPartDocumentObject Or &lt;BR /&gt;&amp;nbsp; &amp;nbsp; docType = DocumentTypeEnum.kAssemblyDocumentObject Or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; docType = DocumentTypeEnum.kDrawingDocumentObject Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&lt;BR /&gt; &lt;BR /&gt;End If&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2012 03:35:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-macro-on-save/m-p/3600878#M134775</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2012-08-30T03:35:51Z</dc:date>
    </item>
  </channel>
</rss>

