Solved

Word template - Change Paper source

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

839 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