<?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: VBA list open documents in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796867#M132052</link>
    <description>&lt;P&gt;Gruff your original post isn't what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just did a test and it loads all the compents of the open file an assembly in this case. I just want the main file that is open added to the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want a list of the components contained in an open file, I just want the names of the open files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is a picture that shows the list populated by your code. plate + rod.iam is the only file open and the only file I want to list, not any subcomponents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------&lt;/P&gt;&lt;P&gt;Update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did find a way to do what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; For Each oDoc In ThisApplication.Documents.VisibleDocuments&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ListBox1.AddItem filename(oDoc.FullFileName)&lt;BR /&gt;&amp;nbsp; Next oDoc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding the .VisibleDocuments so far appears to just reference open documents and not subcomponents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added a second picture to the difference between your code and my code.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2013 21:06:45 GMT</pubDate>
    <dc:creator>pball</dc:creator>
    <dc:date>2013-03-05T21:06:45Z</dc:date>
    <item>
      <title>VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3794184#M132044</link>
      <description>&lt;P&gt;Is there a way to get a list of the currently open documents in VBA?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now to process a bunch of open drawings I simply process the active drawing and then close it, then repeat until all are closed. I'd like to be able to get a list of open documents and switch between them to process them all, which would leave them open.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 22:11:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3794184#M132044</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2013-03-01T22:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3794235#M132045</link>
      <description>&lt;P&gt;Private Sub UserForm_Initialize()&amp;nbsp;&lt;BR /&gt;&amp;nbsp; Dim oDoc As Inventor.Document&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; For Each oDoc In ThisApplication.Documents&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ListBox1.AddItem oDoc.FullFileName&lt;BR /&gt;&amp;nbsp; Next oDoc&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub ListBox1_Click()&lt;BR /&gt;&amp;nbsp; Dim sFile As String&lt;BR /&gt;&amp;nbsp; Dim index As Integer&lt;BR /&gt;&amp;nbsp; index = ListBox1.ListIndex&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; If index &amp;lt; 0 Then Exit Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sFile = ListBox1.List(index)&lt;BR /&gt;&amp;nbsp; ThisApplication.Documents.ItemByName(sFile).Activate&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 23:55:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3794235#M132045</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-01T23:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3795713#M132046</link>
      <description>&lt;P&gt;Thanks, I'll have to give it a shot if I ever get some free time at work lol.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 20:55:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3795713#M132046</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2013-03-04T20:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3795843#M132047</link>
      <description>&lt;P&gt;Yes, that's what i do (thisapplication.Documents), but when you have assemblies open, it counts each component as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is,&amp;nbsp;I have one assembly document "open", but the .count of ThisApplication.Documents returns 97.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 22:22:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3795843#M132047</guid>
      <dc:creator>robmatthews</dc:creator>
      <dc:date>2013-03-04T22:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796681#M132048</link>
      <description>&lt;P&gt;Ok this doesn't seem like it will work then. I just want to list each open assembly, part, and drawing. I just did debug.print ThisApplication.Documents.Count with an assembly and then an assembly drawing and they both gave over 90 which is the amount of parts and stuff in them.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 19:06:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796681#M132048</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2013-03-05T19:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796771#M132049</link>
      <description>&lt;P&gt;Inventor loads only what it needs to for the current documents to build.&lt;BR /&gt;If you load an assembly drawing Inventor will load all components in a super lightweight mode for reference.&lt;BR /&gt;It doesn't list those under ThisApplication.documents.&lt;BR /&gt;&lt;BR /&gt;To fully load all compents you need to start at the top level document and use its AllReferencedDocuments Property&lt;BR /&gt;which returns an enumerated list of all components it takes to create that top level document.&lt;BR /&gt;You would gather The fullfilename property of each component and add them to the list.&lt;BR /&gt;&lt;BR /&gt;If you have many files loaded with many nested components then you will have to&lt;BR /&gt;use the AllReferencedDocuments Property for each and check if each component&lt;/P&gt;&lt;P&gt;fullfilename is in the listbox. if the component filename does not exists in the listbox add it.&lt;BR /&gt;&lt;BR /&gt;When clicking in the listbox you would probably want to use Documents.Open() instead of Documents.Itembyname()&lt;BR /&gt;As the latter will fail if the referenced component is not already fully loaded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Be aware though that fully loading all components like this is memory intensive and you can run out of resources&lt;/P&gt;&lt;P&gt;depending on your system and the size of the components.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 20:10:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796771#M132049</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-05T20:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796807#M132050</link>
      <description>&lt;P&gt;I think you might be misunderstanding what I'm trying to do. As I'm not trying to do anything with components of an assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is a picture showing a few different parts, assemblies, and drawing files open at the same time. I want to make a list of those, not the components of any of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I have those files open, I'd like a list like the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;plate + rod.iam&lt;/P&gt;&lt;P&gt;longbar.idw&lt;/P&gt;&lt;P&gt;bent tube with hole.ipt&lt;/P&gt;&lt;P&gt;rod.ipt&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 20:18:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796807#M132050</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2013-03-05T20:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796831#M132051</link>
      <description>&lt;P&gt;If that is the case then I fail to see why you would not use the code from my original post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only change would be that we write a small function to strip off the fullfilename path information before we&lt;/P&gt;&lt;P&gt;add it to the listbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you still want to make the selected document the active document then you would need&lt;/P&gt;&lt;P&gt;to store the fullfilename in an array or collection so that you could use that with ItemByName()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Function GetFileName(ByVal FullFileName) As String&lt;BR /&gt;&amp;nbsp; Dim nPos As Integer&lt;BR /&gt;&amp;nbsp; Dim sName As String&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; sName = FullFileName&lt;BR /&gt;&amp;nbsp; nPos = InStrRev(sName, "\")&lt;BR /&gt;&amp;nbsp; If nPos &amp;gt; 0 Then&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sName = Mid(sName, nPos + 1)&lt;BR /&gt;&amp;nbsp; End If&lt;BR /&gt;&amp;nbsp; GetFileName = sName&lt;BR /&gt;End Function&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 20:43:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796831#M132051</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-05T20:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: VBA list open documents</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796867#M132052</link>
      <description>&lt;P&gt;Gruff your original post isn't what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just did a test and it loads all the compents of the open file an assembly in this case. I just want the main file that is open added to the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want a list of the components contained in an open file, I just want the names of the open files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is a picture that shows the list populated by your code. plate + rod.iam is the only file open and the only file I want to list, not any subcomponents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------&lt;/P&gt;&lt;P&gt;Update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did find a way to do what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; For Each oDoc In ThisApplication.Documents.VisibleDocuments&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ListBox1.AddItem filename(oDoc.FullFileName)&lt;BR /&gt;&amp;nbsp; Next oDoc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding the .VisibleDocuments so far appears to just reference open documents and not subcomponents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added a second picture to the difference between your code and my code.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 21:06:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-list-open-documents/m-p/3796867#M132052</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2013-03-05T21:06:45Z</dc:date>
    </item>
  </channel>
</rss>

