#1
|
|||
|
|||
Blank VBA box
I have created a macro that would print to a specific printer (not default) and current page only. I've created macros in the past without any problems. But when I run this I get a box displayed on the screen titled Microsoft Visual Basic for Application with white X inside a red circle and buttons for OK, Help.
This is the macro: Sub envelope() ' ' envelope Macro ' ' ActivePrinter = "\\JOHNSONHALL\Laser 4" Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub I've also tried this macro which 'sort of' worked. This selected the printer on the 2nd try but ignored the Current Page: Sub test() ActiveDocument.PrintOut wdPrintCurrentPage ActivePrinter = "\\JOHNSONHALL\Laser 4" End Sub There is a delay when manually selecting a printer which I suspect is part of the problem (system related). The default printer is Adobe PDF which needs to remain in place for another function. I only need WORD to change printer for hard copies. Any thoughts? Thanks! |
#2
|
||||
|
||||
Assuming the printer name is correct then the following should work.
Code:
Sub Envelope() Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\JOHNSONHALL\Laser 4" .DoNotSetAsSysDefault = True .Execute Application.PrintOut Filename:="", Range:=wdPrintCurrentPage, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=False, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 .Printer = sPrinter .Execute End With lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Unfortunately I still get the same blank VBA box. I can create other test macros to change text properties so I'm thinking its something specific to our setup. We've decided to test a .bat file instead.
Thanks anyway Meabh |
#4
|
||||
|
||||
Try recording a macro of the print process. I suspect the issue may relate to the printer name.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
I usually make macros by recording steps rather than writing code (since that's sooo not my forte) but its still displaying the blank VBA box. We run MacAfee pretty much constantly in the back ground which has resulted in slow response time from WORD etc. for many things including like manually changing printer. I even tried adding a pause in between steps but no joy. I double checked the printer name as well just to be safe
|
#6
|
||||
|
||||
Does MacAfee have an option not to process Office files?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
If IF/AND Criteria is Blank, Give me "Blank" | tbesh | Excel | 1 | 09-07-2015 09:43 AM |
Formulato say if cell is blank do this, if not blank do this. | mbesspiata | Excel | 1 | 01-17-2015 05:02 AM |
Row Looks to be blank but its not | bremen22 | Excel Programming | 2 | 01-29-2014 09:07 AM |
Page numberring 1 - blank - 2 - blank etc | Intern | PowerPoint | 0 | 09-02-2011 01:16 AM |
How to turn all blank lines into non-blank for legal forms | sieler | Word | 3 | 04-12-2009 01:38 PM |