Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 1st, 2010, 09:54 AM
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB Script for selecting printer

I have a 30-page Excel report that is printed daily. It could be printed from one of many workstations (each station having a different "default" printer). I would like to write a macro in Excel to automatically select the correct printer and printing mode ("2-sided, flip on short edge").

I tried the SendKeys process, but the program locks up on the last "enter" function. It works fine if I do the last step manually by depressing the enter key. Odd. . . .

I would prefer to use something other than Sendkeys, but I have not found anything that will help (probably because of my minimal experience with coding . . . ).

Here is what I have:

~~~~~~~~~~~~~~~~~~~~~
Sub xxx()

' xxx Macro
' Macro recorded 6/3/2010 by YYYYY

Application.ActivePrinter = "\\EEKIRK1PRN01\KGO2P56 on Ne03:"
SendKeys "%FP"
Application.Wait Now + TimeValue("00:00:01")
SendKeys "%R"
Application.Wait Now + TimeValue("00:00:02")
SendKeys "{TAB 2}"
SendKeys "{DOWN 2}"
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{TAB 9}"
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "{~}", True
End Sub
~~~~~~~~~~~~~~~~~~~~~

As I mentioned, it locks up (e.g., get message that system not responding) when the macro performs the "enter" function. The system works fine if I manually enter the "enter" function. I have also looked at xldialog settings, but to no avail.

Any assistance would be deeply appreciated,

Thank you!
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting A Printer From Code Rood67 Access 0 August 19th, 2008 02:41 PM
Selecting itme from drop down list in script hericles ASP.NET 1.0 and 1.1 Basics 7 August 21st, 2007 01:21 PM
Selecting Printer for CRViewer BillsDanny Pro VB 6 3 April 2nd, 2006 08:41 PM
Printing document from a form & selecting printer lguzman Access VBA 1 June 23rd, 2004 11:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.