Get Document Referenced by Drawing View (VBA)
This example shows how to get the document referenced by a drawing view.
'---------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swView As
SldWorks.View
Dim
swDrawModel As
SldWorks.ModelDoc2
Dim
sModelName As
String
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swView = swSelMgr.GetSelectedObject5(1)
Set
swDrawModel = swView.ReferencedDocument
sModelName
= swView.GetReferencedModelName
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" View
=
" & swView.Name
Debug.Print
" Model
= "
& sModelName
Debug.Print
" "
& swDrawModel.GetPathName
End Sub
'---------------------------------------