dciadmin
Mechanical
- Jul 17, 2002
- 11
Hi,
I am looking to batch print files from Solidworks 6. I have seen the solutions for using Task Scheduler and have seen a couple of the freeware programs available but they don't seem to do what I am looking to do ...
I went to solidworks site and got their vb6 batch print example. It appeared to allow you to change the printer depending on papersize but it doesn't seem to work.
Basically, all I need it to do is be able to specify the printer (which I can now do) and to print to 11x17 paper no matter what the size is set at in solidworks sheet ..
Here is the code that is in the example. I have changed it to print to a specific printer for all sizes. Now I just need the code to force it to print on 11x17 paper on that printer. Does this make sense, or am I missing something?
Private Sub PrintListDraw(lstFileList As ListBox)
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim swDrwDoc As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim NumSheet As Long
Dim vSheetProp As Variant
Dim sModelPrinter As String
Dim nErrors As Long
Dim nWarnings As Long
Dim i As Long
Dim j As Long
' effectively disables VB's implicit QI
On Error Resume Next
Set swApp = CreateObject("SldWorks.Application")
For j = 0 To lstFileList.ListCount - 1
' filter out non-drawing files
If IsDrawingFile(lstFileList.List(j)) Then
Set swModel = swApp.OpenDoc6(lstFileList.List(j), swDocDRAWING, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swDrwDoc = swModel
Debug.Print "File = " + swModel.GetPathName
' blindly go to first sheet in file
NumSheet = swDrwDoc.GetSheetCount
For i = 0 To NumSheet - 1
swDrwDoc.SheetPrevious
Next i
For i = 0 To NumSheet - 1
swDrwDoc.ForceRebuild
Set swSheet = swDrwDoc.GetCurrentSheet
vSheetProp = swSheet.GetProperties
' FIX ME! remove dependence on other form
sModelPrinter = \\server1\Xerox Document Centre 440
Debug.Print " Sheet = " + swSheet.GetName
Debug.Print " PaperSize = " + Str(vSheetProp(0))
Debug.Print " Printer = " + sModelPrinter
swModel.PrintOut2 i + 1, i + 1, 1, False, sModelPrinter, 0#, False, ""
swDrwDoc.SheetNext
Next i
swApp.QuitDoc swModel.GetPathName
End If
Next j
End Sub
I am looking to batch print files from Solidworks 6. I have seen the solutions for using Task Scheduler and have seen a couple of the freeware programs available but they don't seem to do what I am looking to do ...
I went to solidworks site and got their vb6 batch print example. It appeared to allow you to change the printer depending on papersize but it doesn't seem to work.
Basically, all I need it to do is be able to specify the printer (which I can now do) and to print to 11x17 paper no matter what the size is set at in solidworks sheet ..
Here is the code that is in the example. I have changed it to print to a specific printer for all sizes. Now I just need the code to force it to print on 11x17 paper on that printer. Does this make sense, or am I missing something?
Private Sub PrintListDraw(lstFileList As ListBox)
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim swDrwDoc As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim NumSheet As Long
Dim vSheetProp As Variant
Dim sModelPrinter As String
Dim nErrors As Long
Dim nWarnings As Long
Dim i As Long
Dim j As Long
' effectively disables VB's implicit QI
On Error Resume Next
Set swApp = CreateObject("SldWorks.Application")
For j = 0 To lstFileList.ListCount - 1
' filter out non-drawing files
If IsDrawingFile(lstFileList.List(j)) Then
Set swModel = swApp.OpenDoc6(lstFileList.List(j), swDocDRAWING, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swDrwDoc = swModel
Debug.Print "File = " + swModel.GetPathName
' blindly go to first sheet in file
NumSheet = swDrwDoc.GetSheetCount
For i = 0 To NumSheet - 1
swDrwDoc.SheetPrevious
Next i
For i = 0 To NumSheet - 1
swDrwDoc.ForceRebuild
Set swSheet = swDrwDoc.GetCurrentSheet
vSheetProp = swSheet.GetProperties
' FIX ME! remove dependence on other form
sModelPrinter = \\server1\Xerox Document Centre 440
Debug.Print " Sheet = " + swSheet.GetName
Debug.Print " PaperSize = " + Str(vSheetProp(0))
Debug.Print " Printer = " + sModelPrinter
swModel.PrintOut2 i + 1, i + 1, 1, False, sModelPrinter, 0#, False, ""
swDrwDoc.SheetNext
Next i
swApp.QuitDoc swModel.GetPathName
End If
Next j
End Sub