Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Word template - Change Paper source

Posted on 2006-06-22
4
Medium Priority
?
323 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
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

773 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