14 Replies Latest reply on Feb 15, 2019 5:51 AM by Thomas Voetmann

    Need help in ReplaceReference macro

    Kishore K.

      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