<?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-Time Error 91? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946894#M125087</link>
    <description>Comment out the line to replace the reference. If you added the lines to show a list of file names does the new names look correct?</description>
    <pubDate>Wed, 09 Apr 2014 18:53:21 GMT</pubDate>
    <dc:creator>rjay75</dc:creator>
    <dc:date>2014-04-09T18:53:21Z</dc:date>
    <item>
      <title>Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4945930#M125074</link>
      <description>&lt;P&gt;This run-time error 91 doesn't make sense to me. Generally the issue is I didn't define something, but I've noted everything this time.&lt;/P&gt;&lt;P&gt;The error is on this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set f = ThisApplication.ActiveDocument.File&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;ThisApplication is defined towards the beginning. File is defined right before that line.&lt;BR /&gt;&lt;BR /&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;    Option Explicit


    Public Sub ReplaceReference()

    Dim invApp As Inventor.Application
    Set invApp = ThisApplication

    Dim NameStr As String
    Dim NewNamePath As String

    Dim NameStr2 As String
    Dim OldNamePath As String


    NameStr = Renamer.New_Name.Text               'Concatenates the full new file path
    NewNamePath = Renamer.Path_Text.Text &amp;amp; "\" + NameStr &amp;amp; "-" &amp;amp; Right("00" &amp;amp; i, 3) &amp;amp; ".ipt"
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After NewNamePath:" &amp;amp; Err.Description
    Err.Clear

    NameStr2 = Renamer.Old_Name_Display.Text      'Concatenates the old file NAME
    OldNamePath = NameStr2 &amp;amp; "-" &amp;amp; Right("00" &amp;amp; i, 3) &amp;amp; ".ipt"
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After OldNamePath:" &amp;amp; Err.Description
    Err.Clear

    Do While i &amp;lt; 99

    Dim f As File
    Set f = ThisApplication.ActiveDocument.File
    Dim fd As FileDescriptor
        For Each fd In f.ReferencedFileDescriptors
            If fd.FullFileName = OldNamePath Then
                fd.ReplaceReference (NewNamePath)
            End If
        Next


            Loop

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I know run-time error 91 is common and seems silly, but I just don't know what is wrong with it.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 14:08:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4945930#M125074</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T14:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946332#M125075</link>
      <description>&lt;P&gt;Looks like the Do/While is out of sequence. Your current code looks like it's looking for files that match an old file name &amp;nbsp;and switchs the reference to the new file name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One issue is Your Do While i &amp;lt; 99 is in the wrong spot. You set the name up top but begin looping after ward. i never changes. So it could be a memory error as you are running in an inifinite loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your current code The Do While i &amp;lt; 99 should be like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Option Explicit


    Public Sub ReplaceReference()

    Dim invApp As Inventor.Application
    Set invApp = ThisApplication

    Dim NameStr As String
    Dim NewNamePath As String

    Dim NameStr2 As String
    Dim OldNamePath As String

    Do While i &amp;lt; 99
        'Concatenates the full new file path
        NameStr = Renamer.New_Name.Text               
        NewNamePath = Renamer.Path_Text.Text &amp;amp; "\" + NameStr &amp;amp; "-" &amp;amp; Right("00" &amp;amp; i, 3) &amp;amp; ".ipt"
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After NewNamePath:" &amp;amp; Err.Description
        Err.Clear
        'Concatenates the old file NAME
        NameStr2 = Renamer.Old_Name_Display.Text      
        OldNamePath = NameStr2 &amp;amp; "-" &amp;amp; Right("00" &amp;amp; i, 3) &amp;amp; ".ipt"
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After OldNamePath:" &amp;amp; Err.Description
        Err.Clear

        Dim f As File
        Set f = ThisApplication.ActiveDocument.File
        Dim fd As FileDescriptor
        For Each fd In f.ReferencedFileDescriptors
            If fd.FullFileName = OldNamePath Then
                fd.ReplaceReference (NewNamePath)
            End If
        Next
    Loop

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;While this may work there is some redunancies as well. Everytime it's going throught the For Each loop its looping through ever referenced file. In this case you're looping throug 99 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an alternate version that loops through once working for any number of files.&lt;/P&gt;&lt;PRE&gt;   Option Explicit


    Public Sub ReplaceReference()

    Dim invApp As Inventor.Application
    Set invApp = ThisApplication

        Dim NameStr As String
        Dim NewNamePath As String

        Dim NameStr2 As String
        Dim OldNamePath As String

        'Concatenates the full new file path
        NameStr = Renamer.New_Name.Text               
        NewNamePath = Renamer.Path_Text.Text &amp;amp; "\"
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After NewNamePath:" &amp;amp; Err.Description
        Err.Clear
        'Concatenates the old file NAME
        OldNamePath = Renamer.Old_Name_Display.Text      
        If Err.Number &amp;lt;&amp;gt; 0 Then MsgBox "Error Found After OldNamePath:" &amp;amp; Err.Description
        Err.Clear

        Dim sLen As Long
        Dim sep As Long
        Dim fileName as String
        Dim f As File
        Dim fd As FileDescriptor

        Set f = ThisApplication.ActiveDocument.File
        For Each fd In f.ReferencedFileDescriptors            
            sLen = Len(fd.FullFileName)
            sep = InStrRev(fd.FullFileName, "\")
            fileName = Right(fd.FullFileName, sLen - sep)

            If InStr(fileName, OldNamePath) = 1 Then
                fd.ReplaceReference (NewNamePath &amp;amp; Replace(fileName, OldNamePath, NameStr))
            End If
        Next

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This will get the new target directory and new prefix. Then it loops through the referenced files. If any file has a name beginning with the oldname it renames it replaces it with the new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calling Replace("abcde-001.ipt", "abcde", "xyz") returns "xyz-001.ipt".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 15:51:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946332#M125075</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T15:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946450#M125076</link>
      <description>&lt;P&gt;Ah, perfect. Something seemed off about where it was placed but I couldn't figure it out. Going off of your second solution (thanks for that, by the way), I do still get the same error, but this will be great once this error is fixed!!! Thanks, Rodney!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 16:20:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946450#M125076</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T16:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946470#M125077</link>
      <description>2 quick questions. Do you have an assembly open when you run it? What version of Inventor are you running.</description>
      <pubDate>Wed, 09 Apr 2014 16:31:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946470#M125077</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T16:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946506#M125078</link>
      <description>&lt;P&gt;Aha, that moved on to a new error! Yippee! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; I opened an assembly when I did it. This creates a problem though. I need it to run without the assembly document being open when the program is first initialized. The user is supposed to select and open the assembly in part 3 of the program... Hmmm..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I'm running 2011 here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I get on run-time error 5 on this:&lt;/P&gt;&lt;PRE&gt;fd.ReplaceReference (NewNamePath &amp;amp; Replace(fileName, OldNamePath, NameStr))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Baby steps, right? Haha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 16:42:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946506#M125078</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T16:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946518#M125079</link>
      <description>&lt;P&gt;I added an "On Error Resume Next" to forego that problem (it &lt;EM&gt;seems&lt;/EM&gt; to have worked....I think) but still having that new run-time 5 error now&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 16:45:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946518#M125079</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T16:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946572#M125080</link>
      <description>&lt;P&gt;Yet another update, it now runs, but it doesn't do anything. Replace reference should work, right?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 17:08:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946572#M125080</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T17:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946610#M125081</link>
      <description>&lt;P&gt;Try this to see what is giving the error message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change this line:&lt;/P&gt;&lt;PRE&gt;fd.ReplaceReference (NewNamePath &amp;amp; Replace(fileName, OldNamePath, NameStr))&lt;/PRE&gt;&lt;P&gt;to&lt;/P&gt;&lt;PRE&gt;Dim newFileName As String = NewNamePath &amp;amp; Replace(fileName, OldNamePath, NameStr)&lt;BR /&gt;fd.ReplaceReference (newFileName)&lt;/PRE&gt;&lt;P&gt;This will to see which is failing. The string replace function or the ReplaceReference function. It may also fail if newFileName is not a valid file.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 17:19:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946610#M125081</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T17:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946618#M125082</link>
      <description>Also Remove the "On Error Resume Next", this just says skip and restart the loop if you get an error. So if it errors every time it will look like nothing happened.</description>
      <pubDate>Wed, 09 Apr 2014 17:21:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946618#M125082</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T17:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946626#M125083</link>
      <description>&lt;P&gt;That's invalid syntax&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 17:23:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946626#M125083</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T17:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946632#M125084</link>
      <description>&lt;P&gt;Removed that. I'll also attach my code.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 17:25:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946632#M125084</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T17:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946726#M125085</link>
      <description>&lt;P&gt;Got it to mock run through your code. And it worked ok with the final section looking like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Dim sLen As Long
        Dim sep As Long
        Dim FileName As String
        Dim f As File
        Dim fd As FileDescriptor
        Dim Names As String

        'On Error Resume Next
        
        Set f = ThisApplication.ActiveDocument.File
        For Each fd In f.ReferencedFileDescriptors
            sLen = Len(fd.FullFileName)
            sep = InStrRev(fd.FullFileName, "\")
            FileName = Right(fd.FullFileName, sLen - sep)

            If InStr(FileName, OldNamePath) = 1 Then
                Dim NewFileName As String
                NewFileName = NewNamePath &amp;amp; Replace(FileName, OldNamePath, NameStr)
                fd.ReplaceReference (NewFileName)
                Names = Names &amp;amp; vbCrLf &amp;amp; NewFileName
            End If
        Next
        MsgBox Names&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I commented out the Error trapping because we want to know if there's an error here. I added a Names variable so I can get a list of names and display at the end. When run it will show a dialog of all the replaced names. You can temporarily leave the error trap turned on so you can see the list of names to verify them so it doesn't stop on every error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error 5 is on the ReplaceReference call. There 2 reasons why this call is failing.&lt;/P&gt;&lt;P&gt;1. The file name you are trying to replace the reference on does not exist. (The path could be incorrect. Or the name itself could be incorrect.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The file reference you are replacing is not the same as the one being replaced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try running it in an assembly that needs the references replaced with the new files existing already.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 17:59:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946726#M125085</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T17:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946802#M125086</link>
      <description>&lt;P&gt;It won't even compile because of the error 5...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have such a document open too.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 18:23:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946802#M125086</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T18:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946894#M125087</link>
      <description>Comment out the line to replace the reference. If you added the lines to show a list of file names does the new names look correct?</description>
      <pubDate>Wed, 09 Apr 2014 18:53:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946894#M125087</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T18:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946898#M125088</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 18:59:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4946898#M125088</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-09T18:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4947148#M125089</link>
      <description>&lt;P&gt;Do the replacement files exist at this point? If so were they created by just copying the originals?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 20:32:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4947148#M125089</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-09T20:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4948430#M125090</link>
      <description>&lt;P&gt;Yes. Here is how the program works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. User runs program&lt;/P&gt;&lt;P&gt;2. The user clicks browse, which opens a folder dialog&lt;/P&gt;&lt;P&gt;3. In the background, a temporary folder called "Inventor Temp Folder" is created in the C: drive.&lt;/P&gt;&lt;P&gt;4. The contents of the user-selected folder are copied in to this temp folder&lt;/P&gt;&lt;P&gt;5. The user selects okay.&lt;/P&gt;&lt;P&gt;6. The user enters the old prefix of the files and the new one they want&lt;/P&gt;&lt;P&gt;7. The user selects okay&lt;/P&gt;&lt;P&gt;8. The user clicks "Browse for Assemblies", opening a file dialog limited to assembly searches&lt;/P&gt;&lt;P&gt;9. The user selects "Open" and the assembly opens&lt;/P&gt;&lt;P&gt;10. Files are replaced in the assembly with the new corresponding folders (tentative)&lt;/P&gt;&lt;P&gt;11. The temporary folder is deleted (tentative)&lt;/P&gt;&lt;P&gt;12. The assembly is saved and closed (tentative)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 11:36:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4948430#M125090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-10T11:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4948934#M125091</link>
      <description>&lt;P&gt;Would it be better if I made this a whole separate program? So, when the assembly is opened, it can set it to launch that program? Not sure how to do that, but could that fix these problems?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 14:12:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4948934#M125091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-10T14:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4949008#M125092</link>
      <description>&lt;P&gt;EDIT (won't let me):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After the user selects okay, the files in the original folder are renamed.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 14:30:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4949008#M125092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-10T14:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Run-Time Error 91?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4949050#M125093</link>
      <description>&lt;P&gt;You're doing a manual copy design. A few notes and questions that I used to walk through the workflow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. User runs program&lt;/P&gt;&lt;P&gt;2. The user clicks browse, which opens a folder dialog&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;c:\Project1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;3. In the background, a temporary folder called "Inventor Temp Folder" is created in the C: drive.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;c:\Inventor Temp Folder&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;4. The contents of the user-selected folder are copied in to this temp folder&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;c:\Project1 -&amp;gt; c:\Inventor Temp Folder (The files should be renamed at this point)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;5. The user selects okay.&lt;/P&gt;&lt;P&gt;6. The user enters the old prefix of the files and the new one they want&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;Prj1 , Prj2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;7. The user selects okay&lt;/P&gt;&lt;P&gt;8. The user clicks "Browse for Assemblies", opening a file dialog limited to assembly searches&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;Prj1.asm or Prj2.asm (Should be Prj2.asm)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;9. The user selects "Open" and the assembly opens&lt;/P&gt;&lt;P&gt;10. Files are replaced in the assembly with the new corresponding folders (tentative)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;ReplaceReferences should run at this time point files to new location of c:\Inventor Temp Files\Prj2.....&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;11. The temporary folder is deleted (tentative)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#3366FF"&gt;The temporary folder holds the renamed files. They can't be deleted or moved at this point.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;12. The assembly is saved and closed (tentative)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#3366FF"&gt;The assembly is closed and moved.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you don't have access to vault and would like to do this from Inventor here's an alternate workflow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. User opens assembly they wish to copy.&lt;/P&gt;&lt;P&gt;2. User does a SaveAs saving the assembly file to a new folder location.&lt;/P&gt;&lt;P&gt;3. Enters in Prefixes for the old and new files.&lt;/P&gt;&lt;P&gt;4. Programmatically open each referenced file and saveas the file to the new location and name. Close the referenced file. Replace the reference to the newly saved file name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I get a moment I can mock up what the saving/replace procedure looks like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 14:42:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/run-time-error-91/m-p/4949050#M125093</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2014-04-10T14:42:19Z</dc:date>
    </item>
  </channel>
</rss>

