Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2016, 12:37 PM
meabhpowers meabhpowers is offline Blank VBA box Windows 7 32bit Blank VBA box Office 2010 32bit
Novice
Blank VBA box
 
Join Date: Jan 2016
Posts: 3
meabhpowers is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 01-08-2016, 10:48 PM
gmayor's Avatar
gmayor gmayor is offline Blank VBA box Windows 10 Blank VBA box Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 01-11-2016, 07:30 AM
meabhpowers meabhpowers is offline Blank VBA box Windows 7 32bit Blank VBA box Office 2010 32bit
Novice
Blank VBA box
 
Join Date: Jan 2016
Posts: 3
meabhpowers is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 01-11-2016, 08:07 AM
gmayor's Avatar
gmayor gmayor is offline Blank VBA box Windows 10 Blank VBA box Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #5  
Old 01-11-2016, 08:16 AM
meabhpowers meabhpowers is offline Blank VBA box Windows 7 32bit Blank VBA box Office 2010 32bit
Novice
Blank VBA box
 
Join Date: Jan 2016
Posts: 3
meabhpowers is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 01-11-2016, 10:58 PM
gmayor's Avatar
gmayor gmayor is offline Blank VBA box Windows 10 Blank VBA box Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank VBA box If IF/AND Criteria is Blank, Give me "Blank" tbesh Excel 1 09-07-2015 09:43 AM
Blank VBA box Formulato say if cell is blank do this, if not blank do this. mbesspiata Excel 1 01-17-2015 05:02 AM
Blank VBA box 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
Blank VBA box How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft