<?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: Get file names from folder? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598360#M134764</link>
    <description>&lt;P&gt;Just go to Tool, references, and then select as shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/36334iF5BE089062C47C55/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="reference.png" title="reference.png" align="middle" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2012 14:55:49 GMT</pubDate>
    <dc:creator>augusto.goncalves</dc:creator>
    <dc:date>2012-08-28T14:55:49Z</dc:date>
    <item>
      <title>Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3597284#M134759</link>
      <description>&lt;P&gt;I'm trying to get the filenames of some drawings in a folder.&amp;nbsp; I've got the following code, but it's not working.&amp;nbsp; I get a file count from the line "filecount = objFiles.Count", so it's recognizing "objFiles" as the collection of files in the folder, but everything after that simply does nothing.&amp;nbsp; Oddly, I can change the "If" statement from "&amp;lt;&amp;gt;" to "=", and it still reads the "Then" statement in both cases.&amp;nbsp; However, the FileName is blank.&amp;nbsp; What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim objFile As FileDialogs&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFile = New FileDialogs&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objFile.Title = strFolderName&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objFile.StartInDir = "C:\Documents and Settings"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strFolderName = objFile.ShowOpen&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strFolderName = Left$(strFolderName, InStrRev(strFolderName, "\") - 1)&lt;BR /&gt;MsgBox strFolderName&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fso As Object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objFiles As Object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim filecount As Integer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dwgfilenum As Integer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim poo As Variant&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create objects to get a count of files in the directory&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set fso = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; On Error Resume Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFiles = fso.GetFolder(strFolderName).Files&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filecount = objFiles.Count&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For dwgfilenum = 1 To filecount&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Right((objFiles.Item(dwgfilenum).FullFileName), 3) &amp;lt;&amp;gt; "dwg" Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; poo = objFiles.Item(dwgfilenum).FullFileName&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox poo&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'filecount = filecount - 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox filecount&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 21:45:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3597284#M134759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-27T21:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598244#M134760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure this is a Inventor API question, or if you are facing this only inside Inventor VBA engine. ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, I tried the following and it is working fine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;Public Sub test()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fso As New FileSystemObject&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fol As Folder&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set fol = fso.GetFolder("C:\")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each oFile In fol.Files&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print oFile.Name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try again with &lt;STRONG&gt;&lt;U&gt;for each&lt;/U&gt;&lt;/STRONG&gt; instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:09:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598244#M134760</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2012-08-28T14:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598322#M134761</link>
      <description>&lt;P&gt;Probably should have noted that I'm using IV R2010... It recognizes "New FileSystemObject" and "Folder" as a user-defined types, which are not defined.&amp;nbsp; I'm an amateur ar VBA, and the user-defined type is above my level.&amp;nbsp; Thanks for the help, anyway.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:40:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598322#M134761</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-28T14:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598336#M134762</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those types are defined on the system, but you need to add reference to Microsoft Scripting, which will also help you debug your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:46:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598336#M134762</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2012-08-28T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598350#M134763</link>
      <description>&lt;P&gt;How do I add the reference to MS Scripting?&amp;nbsp; If I need to get into the local drive, I'll have to contact I.T. department, not a problem but I'd like to know what to tell them I want done.&amp;nbsp; Thanx.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:51:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598350#M134763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-28T14:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598360#M134764</link>
      <description>&lt;P&gt;Just go to Tool, references, and then select as shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/36334iF5BE089062C47C55/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="reference.png" title="reference.png" align="middle" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:55:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598360#M134764</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2012-08-28T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get file names from folder?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598488#M134765</link>
      <description>&lt;P&gt;I added the MS scripting, but I was also able to get the information I needed with the code I had... I just used a "For Each" statement.&amp;nbsp; Yhanks a bunch for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 15:53:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-file-names-from-folder/m-p/3598488#M134765</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-28T15:53:28Z</dc:date>
    </item>
  </channel>
</rss>

