<?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: Load second vba project file or reference subroutine in other project file in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/8168028#M125735</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've quickly created this code....&lt;/P&gt;&lt;PRE&gt;Public Sub LoadVBAProject()&lt;BR /&gt; LoadAnotherVBAProject "Put Location of VBA project here"&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;Public Sub LoadAnotherVBAProject(pvarLocation As String)&lt;BR /&gt; ' counter to work out the new project number&lt;BR /&gt; Dim varVBACounter As Long&lt;BR /&gt; varVBACounter = ThisApplication.VBAProjects.Count&lt;BR /&gt; ' Open the other project&lt;BR /&gt; ThisApplication.VBAProjects.Open pvarLocation&lt;BR /&gt; ' get a reference to the just opened VBA project&lt;BR /&gt; Dim varTempProject As InventorVBAProject&lt;BR /&gt; Set varTempProject = ThisApplication.VBAProjects(varVBACounter + 1)&lt;BR /&gt; ' references for all the different parts of the VBA project&lt;BR /&gt; Dim varVBAComponent As InventorVBAComponent&lt;BR /&gt; Dim varVBAMember As InventorVBAMember&lt;BR /&gt; Dim varVBAArgument As InventorVBAArgument&lt;BR /&gt; ' go through all the components of the Project and display them&lt;BR /&gt; For Each varVBAComponent In varTempProject.InventorVBAComponents&lt;BR /&gt; ' print to the immediate window the name of the component&lt;BR /&gt; Debug.Print varVBAComponent.Name&lt;BR /&gt; For Each varVBAMember In varVBAComponent.InventorVBAMembers&lt;BR /&gt; ' print to the immediate window the name of the members of the component&lt;BR /&gt; Debug.Print " " &amp;amp; varVBAMember.Name&lt;BR /&gt; For Each varVBAArgument In varVBAMember.Arguments&lt;BR /&gt; Debug.Print " " &amp;amp; varVBAArgument.Name &amp;amp; "----" &amp;amp; varVBAArgument.ArgumentType&lt;BR /&gt; Next varVBAArgument&lt;BR /&gt; Next varVBAMember&lt;BR /&gt; Next varVBAComponent&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;The bit I've forgotten is how to run a Sub in a different project.&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://forums.autodesk.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 15:48:50 GMT</pubDate>
    <dc:creator>Scott_Stubbington</dc:creator>
    <dc:date>2018-07-31T15:48:50Z</dc:date>
    <item>
      <title>Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4861128#M125730</link>
      <description>&lt;P&gt;I'm looking to use two vba project files. I'll have my main ivb file and there is a second ivb file with a single script in it. I do not want to copy that script to the other project file. Is there a way to load or link the second project file from the main one?&lt;BR /&gt;&lt;BR /&gt;Another thing is I've manually loaded a second project file for testing and I can run scripts from it via the Macros option on the Tools ribbon bar but I cannot add them to the ribbon bar under the customize user commands option. If there isn't a way to get scripts from a second project file added on the ribbon bar I don't mind creating a script in the main project which just runs the script from the secondary project file.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 16:45:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4861128#M125730</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2014-03-06T16:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870414#M125731</link>
      <description>added a Reference to it in the calling Project</description>
      <pubDate>Fri, 07 Mar 2014 11:57:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870414#M125731</guid>
      <dc:creator>humbertogo</dc:creator>
      <dc:date>2014-03-07T11:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870574#M125732</link>
      <description>Would you have an example for doing that? Haven't had anything pop up in searches yet, other wise it'll be back to trying slightly difference searches later.</description>
      <pubDate>Fri, 07 Mar 2014 13:17:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870574#M125732</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2014-03-07T13:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870730#M125733</link>
      <description>&lt;P&gt;You can load the 2 project and go to tools references&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/forums/replypage/message-uid/" border="0" alt="" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2014 14:21:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870730#M125733</guid>
      <dc:creator>humbertogo</dc:creator>
      <dc:date>2014-03-07T14:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870784#M125734</link>
      <description>I'm getting an error that says "Automation error, Unspecified error" when I try adding the 2nd project as a reference and it won't add the reference. Well I didn't really want to but I guess I'll just copy that one script to my project until I can figure something out.</description>
      <pubDate>Fri, 07 Mar 2014 14:36:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/4870784#M125734</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2014-03-07T14:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/8168028#M125735</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've quickly created this code....&lt;/P&gt;&lt;PRE&gt;Public Sub LoadVBAProject()&lt;BR /&gt; LoadAnotherVBAProject "Put Location of VBA project here"&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;Public Sub LoadAnotherVBAProject(pvarLocation As String)&lt;BR /&gt; ' counter to work out the new project number&lt;BR /&gt; Dim varVBACounter As Long&lt;BR /&gt; varVBACounter = ThisApplication.VBAProjects.Count&lt;BR /&gt; ' Open the other project&lt;BR /&gt; ThisApplication.VBAProjects.Open pvarLocation&lt;BR /&gt; ' get a reference to the just opened VBA project&lt;BR /&gt; Dim varTempProject As InventorVBAProject&lt;BR /&gt; Set varTempProject = ThisApplication.VBAProjects(varVBACounter + 1)&lt;BR /&gt; ' references for all the different parts of the VBA project&lt;BR /&gt; Dim varVBAComponent As InventorVBAComponent&lt;BR /&gt; Dim varVBAMember As InventorVBAMember&lt;BR /&gt; Dim varVBAArgument As InventorVBAArgument&lt;BR /&gt; ' go through all the components of the Project and display them&lt;BR /&gt; For Each varVBAComponent In varTempProject.InventorVBAComponents&lt;BR /&gt; ' print to the immediate window the name of the component&lt;BR /&gt; Debug.Print varVBAComponent.Name&lt;BR /&gt; For Each varVBAMember In varVBAComponent.InventorVBAMembers&lt;BR /&gt; ' print to the immediate window the name of the members of the component&lt;BR /&gt; Debug.Print " " &amp;amp; varVBAMember.Name&lt;BR /&gt; For Each varVBAArgument In varVBAMember.Arguments&lt;BR /&gt; Debug.Print " " &amp;amp; varVBAArgument.Name &amp;amp; "----" &amp;amp; varVBAArgument.ArgumentType&lt;BR /&gt; Next varVBAArgument&lt;BR /&gt; Next varVBAMember&lt;BR /&gt; Next varVBAComponent&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;P&gt;The bit I've forgotten is how to run a Sub in a different project.&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://forums.autodesk.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:48:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/8168028#M125735</guid>
      <dc:creator>Scott_Stubbington</dc:creator>
      <dc:date>2018-07-31T15:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/8168039#M125736</link>
      <description>&lt;P&gt;Ah pants, sorry folks, I didn't look at the date. &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:50:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/8168039#M125736</guid>
      <dc:creator>Scott_Stubbington</dc:creator>
      <dc:date>2018-07-31T15:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/9092830#M125737</link>
      <description>&lt;P&gt;Why do you apologize for answering an old post, that hasn't been satisfyingly answered yet?&lt;/P&gt;&lt;P&gt;Kept me busy too, so here is what I have figured out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your proposed method works, but i find it somewhat laborious to pass arguments and results. Working with references to other projects is much "smoother" - if there wasn't a big catch:&lt;/P&gt;&lt;P&gt;You can create a new Project, and then put a reference to it in your Default.ivb, and everything works fine until you save everything, shut down Inventor and restart it the next day: The reference in your Default.ivb is broken! (funny detail: if you consult the broken&amp;nbsp;reference's "IsBroken"-property,&amp;nbsp;it does not reply "true", but causes an error instead&amp;nbsp;- It's just like asking someone if he is asleep: the answer is either "no" or there's no answer).&lt;/P&gt;&lt;P&gt;That is because Inventor's VBA-client ins't smart enough to load referenced projects automatically. The referenced project must be loaded prior to the referencing project if the references shall still work (btw: Excel is smart enough to behave as one would reasonably expect).&lt;/P&gt;&lt;P&gt;Thus, you cannot have your Default.ivb reproducably reference a second project for easy passing of arguments and results, but you can create an - admittedly somewhat complicated - workaround, where you can youse your Default.ivb to reproducably load two or&amp;nbsp;more&amp;nbsp;projects in the correct order, and then use them with references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached some project's where this is demonstrated with some simple functions. It also shows how to pass arguments and receive results when not working with references. (Your post didn't make that very clear, sorry)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 16:19:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/9092830#M125737</guid>
      <dc:creator>Bert_Bimmel</dc:creator>
      <dc:date>2019-10-17T16:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Load second vba project file or reference subroutine in other project file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/13834867#M177319</link>
      <description>&lt;P&gt;I'm in the exact same boat here, I'm trying to have more than one project load when Inventor starts up, at this point I really don't care what kind of project it loads, Application, Document or User, as long as it load on Inventor startup&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2025 19:25:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/load-second-vba-project-file-or-reference-subroutine-in-other/m-p/13834867#M177319</guid>
      <dc:creator>mgrenier2</dc:creator>
      <dc:date>2025-10-02T19:25:53Z</dc:date>
    </item>
  </channel>
</rss>

