Solved

Word template - Change Paper source

Posted on 2006-06-22
4
314 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now