Open Drawing Document Read-only Example (VBA)
This example shows how to open a drawing document as read-only.
'------------------------------------------------------
'
' Preconditions: Specified file to open exists.
'
' NOTE: The
specified file in this example is shipped as a
' sample
file for a SolidWorks tutorial. After
' opening
the file with this macro, close it without saving it so
' that
it will continue to work with the tutorial.
'
' Postconditions: Specified file is opened as view-only.
'
'------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDocSpecification As SldWorks.DocumentSpecification
Dim sName As String
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set swDocSpecification = swApp.GetOpenDocSpec("C:\Program
Files\SolidWorks\SolidWorks\samples\tutorial\AutoCAD\7550-021.slddrw")
sName = swDocSpecification.FileName
swDocSpecification.DocumentType
= swDocDRAWING
swDocSpecification.ReadOnly
= True
swDocSpecification.Silent
= False
Set swModel = swApp.OpenDoc7(swDocSpecification)
longstatus = swDocSpecification.Error
longwarnings = swDocSpecification.Warning
End Sub