VBA Printer options not affecting print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've noticed weird behavoir with this code to print drawings since I've started to use it, but I've never really tried getting to the bottom of it since it not usually a problem. The problem is I'll set certain options and then they aren't applied to the print job.
I don't know if I'm doing something wrong, but this code I found doesn't want to change the paper size and color options.
When set it to use 11x17 paper it will print 8.5x11 which is the default size for the printer. So if I change the printer options to default to 11x17 it will print with 11x17. Changing the color between color, greyscale, and blackandwhite don't affect the prints either.
Also is there a way to detect the default printer since I noticed when I "printed" a pdf manually and then tried this script it used the pdf printer and not the default printer, which I would always want to use.
Public Sub Single_Print_11x17()
Dim oPrintMgr As PrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
If MsgBox("Using default printer """ & oPrintMgr.printer & """ with 11x17 paper. Do you want to continue?", vbYesNo + vbQuestion) = vbNo Then Exit Sub
Print_doc printer:=oPrintMgr.printer, paper:=kPaperSize11x17, black_white:=True
End SubIf you notice that i'm not using two of the arguements in the function that are passed, that's because they don't appear to affect anything so I just left some of it hard coded. When/if I can get the different options working I'll start using the arguements more since I have plans.
Function Print_doc(ByVal printer As String, ByVal paper As String, ByVal black_white As Boolean)
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then Exit Function
Dim oDrgDoc As DrawingDocument
Set oDrgDoc = ThisApplication.ActiveDocument
Dim oDrgPrintMgr As DrawingPrintManager
Set oDrgPrintMgr = oDrgDoc.PrintManager
'choose printer works
oDrgPrintMgr.printer = printer
'choose sheets works
oDrgPrintMgr.PrintRange = kPrintAllSheets
'choose size doesn't work
oDrgPrintMgr.PaperSize = kPaperSize11x17
'choose scale works
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
'color/black & white don't work
oDrgPrintMgr.ColorMode = kPrintGrayScale
oDrgPrintMgr.AllColorsAsBlack = black_white
oDrgPrintMgr.SubmitPrint
End Function
I'd love to get all these options working since I want to be able to select size and color options when using my print scripts.
pball's Autodesk Forum Style
Userscript to edit forum links to jump to first unread post
Jump To First Post Userscript
