Message 1 of 4
Replace Reference in vb net
Not applicable
06-14-2017
12:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
how to replace references in VB Net
Sub ReplaceFile(parent As String, oldfilename As String, newfilename As String)
Dim oDoc As Inventor.Document
oDoc = OpenFileCad(parent)
If IsNothing(oDoc) Then
Exit Sub
End If
If Not FileExists(newfilename) Then
Exit Sub
End If
Dim allReferencedFiles As Object
allReferencedFiles = oDoc.File.ReferencedFileDescriptors
Dim ofd As FileDescriptor = Nothing
oldfilename = oldfilename.ToLower
Dim t As String = ""
For Each ofd In allReferencedFiles
Debug.Print(ofd.FullFileName & " " & FileExists(ofd.FullFileName).ToString)
t = ofd.FullFileName.ToLower
If t = oldfilename Then
ofd.ReplaceReference(newfilename)
Exit For
End If
Next
End SubI tried with this code but does not work
Thanks Regards
