Replace Referenced Document Example (VBA)
This example shows how to replace a referenced document with a different
document
'-----------------------------------------
'
' Preconditions:
' (1)
c:\samples\whistles.sldasm, whistle.sldprt, and whistleLonger.sldprt
' exist.
' (2)
c:\samples\whistles.sldasm is not open.
'
' Postconditions: c:\samples\whistleLonger.sldprt replaced
c:\samples\whistle.sldprt
' reference
within c:\samples\whistles.sldasm.
'
'-----------------------------------------
Option Explicit
Const sReferencingDoc As
String = "c:\samples\whistles.sldasm"
Const sOldDoc As
String = "c:\samples\whistle.sldprt"
Const sNewDoc As
String = "c:\samples\whistleLonger.sldprt"
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
bRet As
Boolean
Set
swApp = CreateObject("SldWorks.Application")
bRet
= swApp.ReplaceReferencedDocument(sReferencingDoc,
sOldDoc, sNewDoc)
Debug.Assert
bRet
End Sub