Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Owner2229
in reply to: Wind_Talker

Hi, you can try this:

 

 

Dim PatternName As String = "Component Pattern 1:1" ' This is the Pattern you want to search for
Dim OldFile As String = "MyFile1"                   ' This is the part you want to replace, without extension
Dim NewFile As String = "C:/MyPath/MyFile2.ipt" ' This is the replacing part, full path Dim oDoc As Document = ThisApplication.ActiveDocument Dim oOcc As ComponentOccurrence For Each oOcc In oDoc.ComponentDefinition.Occurrences Dim oName As String = oOcc.Name
Dim FNP As Integer = InStrRev(oName, ":", -1)
oName = Left(oName, FNP - 1)
If Not oName = OldFile Then Continue For
Try If Not oOcc.PatternElement.Type.ToString = "kOccurrencePatternElementObject" Then Continue For Catch Continue For End Try Dim oElement As OccurrencePatternElement = oOcc.PatternElement Dim oParent As Object = oElement.Parent If oParent.Name = PatternName Then oOcc.Replace(NewFile, False) ' False to not replace all occurrences End If Next

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods