ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
JRJason Raak24/08/2011

Hello All,

I am trying to write a macro that will print a drawing on Letter sized paper "Scaled to Fit" and then close the drawing without saving.  I have the print part of the macro working but I have been unable to get the close without saving part to work.  Below is the macro that I have so far.  Any suggestions on what I need to change?

Dim swApp As Object

Dim myPageSetup As Object

Dim Part As Object

Dim swModelName() As String

Dim vModelNameArr As Variant

Dim vModelName As Variant

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Set myPageSetup = Part.PageSetup

myPageSetup.ScaleToFit = True

myPageSetup.PrinterPaperSize = 1

'Part.PrintDirect

Set swModel = swApp.GetFirstDocument

ReDim swModelName(0)

swModelName(UBound(swModelName)) = swModel.GetTitle

ReDim Preserve swModelName(UBound(swModelName) + 1)

ReDim Preserve swModelName(UBound(swModelName) - 1)

vModelNameArr = swModelName

Debug.Print "Closing:  " + vModelName

swApp.QuitDoc vModelName

End Sub

Thanks in advance!