CycloneWade
Automotive
- Apr 1, 2005
- 76
So i had this macro working a couple months ago and now it has a compile error. Object library feature not supported. This is almost a straight copy from API help files. Thanks.
Dim swApp As Object
'-----------------------------------------------------
'
' Preconditions: Drawing document is open.
'
' Postconditions: Drawing document printed to file.
'
'------------------------------------------------------
Option Explicit
Sub main()
' Printer
Const SWPrinter As String = "\\DSM\HP LaserJet 3300/3310/3320"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDocExt As SldWorks.ModelDocExtension
Dim swDraw As SldWorks.DrawingDoc
Dim PathName As String
Dim PrintFileName As String
Dim nPrintSheets(1) As Long
Dim vPrintSheets As Variant
Dim DefPrinter As String
Dim i As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDocExt = swModel.Extension
Set swDraw = swModel
' Strip off SolidWorks file extension (.sldxxx)
PathName = swModel.GetPathName
PathName = Left(PathName, Len(PathName) - 7)
For i = 0 To swDraw.GetSheetCount - 1
' Generate print filename based on sheet number
' For example, if drawing document is gears.slddrw and contains
' one sheet, then the print filename is gears0.prn
PrintFileName = PathName & 0 & Trim(Str(i + 1)) & ".prn"
' Print out one sheet at a time
nPrintSheets(0) = i + 1
vPrintSheets = nPrintSheets
swDocExt.PrintOut2 (vPrintSheets), 1, False, SWPrinter, PrintFileName
Next i
End Sub
'______________
Dim swApp As Object
'-----------------------------------------------------
'
' Preconditions: Drawing document is open.
'
' Postconditions: Drawing document printed to file.
'
'------------------------------------------------------
Option Explicit
Sub main()
' Printer
Const SWPrinter As String = "\\DSM\HP LaserJet 3300/3310/3320"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDocExt As SldWorks.ModelDocExtension
Dim swDraw As SldWorks.DrawingDoc
Dim PathName As String
Dim PrintFileName As String
Dim nPrintSheets(1) As Long
Dim vPrintSheets As Variant
Dim DefPrinter As String
Dim i As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDocExt = swModel.Extension
Set swDraw = swModel
' Strip off SolidWorks file extension (.sldxxx)
PathName = swModel.GetPathName
PathName = Left(PathName, Len(PathName) - 7)
For i = 0 To swDraw.GetSheetCount - 1
' Generate print filename based on sheet number
' For example, if drawing document is gears.slddrw and contains
' one sheet, then the print filename is gears0.prn
PrintFileName = PathName & 0 & Trim(Str(i + 1)) & ".prn"
' Print out one sheet at a time
nPrintSheets(0) = i + 1
vPrintSheets = nPrintSheets
swDocExt.PrintOut2 (vPrintSheets), 1, False, SWPrinter, PrintFileName
Next i
End Sub
'______________