Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Specifying a Paper Tray in a Macro.
Written by Allen Wyatt (last updated July 19, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003
If you use macros to print your worksheets, you already know that the macro can specify the actual printer to which output should be sent. What if you want to also specify a specific paper tray to be used on that printer? Unfortunately, this gets to be a bit of a sticky wicket. The problem is that when you click on the Options button in the Page Setup dialog box in order to set which paper tray to use, what you see is completely under the control of your printer driver, not under the control of Excel.
What does this mean to you? It means there are no commands you can use in an Excel macro to specify a printer tray. There are some workarounds that you can try, however. The first workaround is to simply define different printer definitions in Windows, each one tailored to use a specific printer tray. Follow these general steps:
At this point you have multiple printer definitions set up, and each will print to a different paper tray on the same printer. Within Excel you can specify the desired printer, in a macro, so that the printout goes to the desired printer definition, and hence to the desired paper tray. The only drawback to this solution, of course, is that it takes quite a bit of setup work. If you work in an office with 50 users, this means you will need to make sure all 50 have each printer defined as described above.
Another workaround involves the use of the SendKeys statement in your macro. You can find information on SendKeys in the VBA online help available with Excel, but what it basically does is to stuff the keyboard buffer with a series of keypresses, just as they would be typed by the user. Thus, you could theoretically set up the macro to emulate the keypresses you would follow to open the Page Setup dialog box, click on Options, and select a different printer tray.
There is a potential problem with SendKeys, however. It can be unreliable because there is no way to insure that the keystrokes are actually going where you want. On a multi-threaded operating system (like Windows), some other process could intervene and derail the commands. In addition, if SendKeys works on your computer, it may not work on someone else's computer unless they have the same version of Excel, same printer, and same printer driver version.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2213) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Specifying a Paper Tray in a Macro.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Excel allows you to repeat rows at the top of every page of a printout. If you want to repeat rows at the bottom of every ...
Discover MoreWhen you print a worksheet, you may want to specify that the printout be done on a particular paper tray in a particular ...
Discover MoreNeed to print just a portion of a worksheet? It's easy to do if you follow the steps in this tip.
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments