代码:

Option Explicit

Const TRAININGDIR As String = _
  "D:\Application Data\SolidWorks\文章\TRN_CDT2315_API2023\SOLIDWORKS Training Files\API Fundamentals"
Const TEMPLATEDIR As String = _
  "C:\ProgramData\SolidWorks\SOLIDWORKS 2022\templates\"
Const TEMPLATENAME As String = _
  TEMPLATEDIR & "gb_a1.drwdot"

Dim errors As Long
Dim warnings As Long
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim retval As Boolean
Dim swView As SldWorks.View

Sub main()

  Set swApp = Application.SldWorks
  Set swModel = swApp.ActiveDoc
  Set swDraw = swApp.NewDocument(TEMPLATENAME, _
    swDwgPaperA1size, 0#, 0#)

'swDraw.EditTemplate
swDraw.EditSheet

      retval = swDraw.Create3rdAngleViews2(swModel.GetPathName)
            
    Dim RebuildSuccess As Boolean
    RebuildSuccess = swDraw.ForceRebuild3(True) 'ModelDoc2.ForceRebuild3

End Sub

当前工程图的文件名:

Option Explicit

Dim errors As Long
Dim warnings As Long

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc

Sub main()
  Set swApp = Application.SldWorks
  Set swModel = swApp.ActiveDoc
  Set swDraw = swModel

swApp.SendMsgToUser swDraw.GetPathName
End Sub

当前工程图另存为dwg:

Option Explicit

Dim errors As Long
Dim warnings As Long

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc

Sub main()
  Set swApp = Application.SldWorks
  Set swModel = swApp.ActiveDoc
  Set swDraw = swModel

Dim s As String
s = swDraw.GetPathName

    swDraw.Extension.SaveAs s & ".DWG", _
      swSaveAsCurrentVersion, swSaveAsOptions_Silent, _
      Nothing, errors, warnings

    ' swDraw.Extension.SaveAs s & ".DXF", _
    '   swSaveAsCurrentVersion, swSaveAsOptions_Silent, _
    '   Nothing, errors, warnings

    ' swDraw.Extension.SaveAs s & ".JPG", _
    '   swSaveAsCurrentVersion, swSaveAsOptions_Silent, _
    '   Nothing, errors, warnings

    ' swDraw.Extension.SaveAs s & ".TIF", _
    '   swSaveAsCurrentVersion, swSaveAsOptions_Silent, _
    '   Nothing, errors, warnings

End Sub