Solved

Word template - Change Paper source

Posted on 2006-06-22
4
321 Views
Last Modified: 2009-07-29
I need some VBA code that I can insert into a word template.

The code will detected which printer is my default and dependent on this it will change my page setup | paper source to letterhead using the ID for each printer.

If activeprinter=1809, 1802, 1801, 1704
then
firstpage = 1
otherpages = 1

else
firstpage = 2
otherpages = 2

Thanks
Priscilla
0
Comment
Question by:Priscilla_Hora
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17021367
Something like this should get the job done.  Be sure to change the trays as desired.

Dim WithEvents wrdApp As Word.Application

Private Sub Document_Open()
    Set wrdApp = Application
End Sub

Private Sub wrdApp_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
    With Doc.PageSetup
        Select Case Trim(Left(wrdApp.ActivePrinter, InStr(wrdApp.ActivePrinter, " on ")))
            Case "Printer Name #1"
                .FirstPageTray = wdPrinterAutomaticSheetFeed
                .OtherPagesTray = wdPrinterMiddleBin
                Cancel = False
            Case "Printer Name #2"
                .FirstPageTray = wdPrinterAutomaticSheetFeed
                .OtherPagesTray = wdPrinterMiddleBin
                Cancel = False
            Case Else
                Cancel = True
        End Select
    End With
End Sub
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question