Printing a Document with SendKeys

Mindwatering Incorporated

Author: Tripp Black

Created: 05/09/2009 at 11:34 PM

 

Category:
Notes Developer Tips
LotusScript

Using Sendkeys to change the page setup of a document in the print dialog and choose landscape.
Note: You may likely have to adjust the dialog depending on version of Notes, Windows, and Printer.

Dim WshShell As Variant
Dim tabcount As Integer

Set WshShell = CreateObject("WScript.Shell")

' print (CTRL-P)
WshShell.SendKeys "^p"

' tab to the "page setup tab - ADJUST THIS TO YOUR ENVIRONMENT
For tabcount = 0 To 12
WshShell.SendKeys "{TAB}"
Next tabcount

' select the tab via right arrow key
WshShell.SendKeys "{RIGHT}"

' select "Landscape" via (ALT-A)
WshShell.SendKeys "%a"
' print by clicking <ENTER>
WshShell.SendKeys "{ENTER}"

This solutions stinks. However, Using the printer object via the GUI doesn't always work either. So there isn't a good solution. The old code that worked w/XP and sortof 2000 is broken for XP.

previous page