MACRO LIBRARY

Lesson 3.1 homework part A solution

Free public access. No account or subscription required.

Files

Lesson 3.1 homework part A solution

Code

'Homework 3.1a
'Save a three-sheet drawing named 1.SLDDRW to your desktop. Create a macro that opens the _
    drawing in lightweight so that Sheet2 is active. _
    Note: If you use the solution code, be sure to modify the file path.
    
Const strFileLocation As String = "C:UsersKeithDesktop1.SLDDRW"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDocSpec As SldWorks.DocumentSpecification
    
Sub main()
    Set swApp = Application.SldWorks
    Set swDocSpec = swApp.GetOpenDocSpec(strFileLocation)
    swDocSpec.SheetName = "Sheet2"
    swDocSpec.UseLightWeightDefault = False
    swDocSpec.LightWeight = True
    Debug.Print "Error: " & swDocSpec.Error
    Debug.Print "Warning: " & swDocSpec.Warning
    swApp.OpenDoc7 swDocSpec
End Sub