VBA code to change printer settings

cresswell80

New Member
Joined
Oct 12, 2005
Messages
46
Hi all,

I need some code that will allow me to change the printer settings - the setting i want to change is the paper type (plain to letterhead).

I plan to have 2 buttons on my toolbar - one that prints letterhead and one that prints on plain...any ideas?

I've tried using sendkeys btw, but didn't work!

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
seems theres no code to specify printer settings.. the link above was using sendkeys which i can't get to work...

can anybody pick anything wrong with this??:

Code:
Sub SET_LETTERHEAD()
    '- change Printer setting to LETTERHEAD
    Dim AltKey As String
    Dim CtrlKey As String
    Dim ShiftKey As String
    Dim TabKey As String
    Dim EnterKey As String
    Dim DownKey As String
    Dim PgUp As String
    Dim UpKey As String
    Dim EscKey As String
    '--------------------------
    AltKey = "%"
    CtrlKey = "^"
    ShiftKey = "+"
    TabKey = "{TAB}"
    EnterKey = "~"
    DownKey = "{DOWN}"
    PgDnKey = "{PGUP}"
    UpKey = "{UP}"
    EscKey = "{ESC}"
    '--------------------------
    '- open print dialog 'File/Print'
    SendKeys AltKey & "(FP)", False
    '- delay 1 second
    'Application.Wait Now + TimeValue("00:00:01")
    '- open printer properties
    SendKeys AltKey & "(P)", False
    '- move along tabs to paper
    SendKeys CtrlKey & PgUpKey, False
    '- 6 tabs to paper type
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    '- change to Letterhead
    '- assuming currently set to plain
    SendKeys DownKey, False
    SendKeys DownKey, False
    SendKeys DownKey, False
    SendKeys DownKey, False
    '- Enter twice to print page
    SendKeys EnterKey, False
    SendKeys EnterKey, False
    'Reset to plain
    SendKeys AltKey & "(FP)", False
    SendKeys AltKey & "(P)", False
    SendKeys CtrlKey & PgUpKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys TabKey, False
    SendKeys UpKey, False
    SendKeys UpKey, False
    SendKeys UpKey, False
    SendKeys UpKey, False
    SendKeys EnterKey, False
    SendKeys EscKey, False
End Sub

thanks
 
Upvote 0
The link suggested adding a printer for each paper tray you want to use. Then you just need to specify the printer in code.
 
Upvote 0

Forum statistics

Threads
1,203,080
Messages
6,053,410
Members
444,662
Latest member
AaronPMH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top