AnsweredAssumed Answered

Need help in ReplaceReference macro

Question asked by Kishore K. on Feb 6, 2019
Latest reply on Feb 15, 2019 by Thomas Voetmann

Hi Friends,


I want to replace the part files in the assembly by using ReplaceReference method. I wrote the same codes in the macro but I'm getting an run time error.


Please guide me if I miss something?


Option Explicit

Dim swApp As Object

Dim swModel As ModelDoc2

Dim OriginalReference As String

Dim ReplacementReference As String


Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

If swModel Is Nothing Then Exit Sub

OriginalReference = "old location"

ReplacementReference = "new location"

swApp.ReplaceReference OriginalReference, ReplacementReference


End Sub