Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey,
I am working on a piece of code so that you can choose which pages you want to print and then print them immediately.
The code works fine. You choose the pages and print on printing and you can print the chosen pages. You need to be able to put a check mark on the sheet you want to print. Because of this there is a lot of extra code.
I was wondering if anyone knows how to clean up my code? Or maybe does someone knows another way to switch between true and false? For 3 pages it is still possible, but in the end I have a lot more pages.
Thanks in advance
Dim oDrgDoc As DrawingDocument Dim oDrgPrintMgr As DrawingPrintManager oDrgDoc = ThisApplication.ActiveDocument oDrgPrintMgr = oDrgDoc.PrintManager ' Switch between true and false If Sheet1 = True Then oSheet1 = False Else oSheet1 = True End If If Sheet2 = True Then oSheet2 = False Else oSheet2 = True End If If Sheet3 = True Then oSheet3 = False Else oSheet3 = True End If ' Provide the good status to the page ThisDoc.Document.Sheets.Item("Sheet:1").ExcludeFromPrinting = oSheet1 ThisDoc.Document.Sheets.Item("Sheet:2").ExcludeFromPrinting = oSheet2 ThisDoc.Document.Sheets.Item("Sheet:3").ExcludeFromPrinting = oSheet3 '--------Printing-------- 'Printer name oDrgPrintMgr.Printer = "Microsoft Print to PDF" oDrgPrintMgr.SetSheetRange(1,3) 'Paper size, scale and orientation oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSize11x17 oDrgPrintMgr.PrintRange = PrintRangeEnum.kPrintSheetRange oDrgPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation oDrgPrintMgr.SubmitPrint()
Solved! Go to Solution.