Message 1 of 23

Not applicable
04-09-2014
07:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
The error is on this line:
Set f = ThisApplication.ActiveDocument.File
ThisApplication is defined towards the beginning. File is defined right before that line.
Here is my code:
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 & "\" + NameStr & "-" & Right("00" & i, 3) & ".ipt" If Err.Number <> 0 Then MsgBox "Error Found After NewNamePath:" & Err.Description Err.Clear NameStr2 = Renamer.Old_Name_Display.Text 'Concatenates the old file NAME OldNamePath = NameStr2 & "-" & Right("00" & i, 3) & ".ipt" If Err.Number <> 0 Then MsgBox "Error Found After OldNamePath:" & Err.Description Err.Clear Do While i < 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
I know run-time error 91 is common and seems silly, but I just don't know what is wrong with it.
Solved! Go to Solution.