Need help in ReplaceReference macro

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

Regards,

Kishore

SolidworksApi/macros