Problems with Macros

  • Thread starter Thread starter galatea2153
  • Start date Start date
G

galatea2153

Hi - I'm using XP SP2 and Office 2007. I'm trying to write a macro to send
documents to a particular tray (say tray 1 or 2) on a particular printer
(printer 2). (Currently I have to go to Print/Choose Printer
2/Properties/Choose Tray 1 etc etc). I thought it would be a relatively easy
thing to record a macro, using mouseclicks, as it's not a complicated
procedure, just an annoying one!

Anyway - macro seems to record okay, but doesn't actually work! What it
does, instead, is change my default printer from my printer (printer 1) to
printer 2; and only takes paper from Tray 1, rather than either tray
(depending on which macro I use).

I thought this might be because I'm connected to Printer 2 via a network ...
however, I've tried to create the same macro on Printer 2's computer, and
virtually the same thing happens.

I'm at a bit of a loss, and would appreciate any help. I hope my
explanation is clear enough! (By the way - I know nothing about VBE, I only
know how to create macros by using mouse-clicks or keystrokes).

Thanks in advance,

Megan
 
The following should work:

Sub LaserTray2()
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
ActivePrinter = "Put the name of the required printer here"
With Options
.DefaultTray = "Set the tray option here"
End With
Application.PrintOut FileName:=""
With Options
.DefaultTray = "Use printer settings"
End With
ActivePrinter = sCurrentPrinter
End Sub

See also http://www.gmayor.com/fax_from_word.htm and
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top