Archive of Mr Excel Message Board
Back to Printing in Excel archive index
Back to archive home
how do I use nprint (in DOS) to print Excel files?Posted by Darrell Hahn on August 25, 1999 8:25 AM
I am writing a macro that (hopefully) will print a shared Excel file to a specific printer, regardless of where the user is. This proves to be difficult, since printers are set up differently on individual machines, making it impossible to set ActivePrinter=whatever. So I'm trying to use "nprint" in DOS, where I can just type the name of the printer. But when I print an excel file using nprint, I lose all colors/formatting/etc. Does anyone know of a way to tell nprint that this is an excel file and should print accordingly?
Re: how do I use nprint (in DOS) to print Excel files?Posted by Chris on August 25, 1999 12:34 PM
If the printer is a network printer, why would it have different names on different machines? Setting the ActivePrinter property should work just fine.
Re: how do I use nprint (in DOS) to print Excel files?Posted by Darrell on August 25, 1999 1:53 PM
When Joe sets up the printer on his machine, he calls it "The printer by the elevator." When Sarah sets up the printer on her machine, she calls it "The printer near the exit." Both are the same printer, but they have different names. In order to use ActivePrinter=, you'd have to use either ActivePrinter = "The printer by the elevator on \\server\printer," or ActivePrinter = "The printer near the exit on \\server\printer." But I would like to write a macro where the document would be printed to the same printer, regardless of which machine is being used.
Re: how do I use nprint (in DOS) to print Excel files?Posted by Chris on September 01, 1999 5:55 AM
I'm sorry that I don't have a very good answer for you. I'm not familiar with any API calls to get a list of installed printers. My idea was that if you had a list of the installed printers you could search the text for the part of the name that was always the same. The only thing I can think of, and I sure you won't want to do it, is to use the SendKeys command to select a printer from the print dialog. Then check the string using ActivePrinter.Name. Then if that isn't the right printer, you would go through the process again. See what I mean about not liking this answer.
Our IS folks don't let the users change the LAN printer names, now I know why.
Re: how do I use nprint (in DOS) to print Excel files?Posted by Darrell on September 03, 1999 10:49 AM
Hi Chris - Thanks for putting some more thought in to it. Yeah, I was thinking, too, that it would be pretty easy to search through a list of available printers and choose the correct one by choosing the string that contained the correct printer. Alas, I'm not sure how to get a list of installed printers! I tried using SendKeys to do exactly what you said, to go to the Print Dialog and choose a printer, but I couldn't even get it to choose ANY printer, much less a specific printer. Thanks again.
Re: how do I use nprint (in DOS) to print Excel files?Posted by Chris on September 08, 1999 6:25 AM
If you really want to give the SendKeys a shot, here's the code to pick the first printer on the list:
If you wanted the second printer on the list, you would add this line after sending the HOME key:
Re: how do I use nprint (in DOS) to print Excel files?Posted by Ivan Moala on September 09, 1999 2:35 AM
The above routine will work fine, just don't
test it from your VBE !! as the sendkeys
works on the Active Application which would be
your VBE, you could get undersirable effects!
So using sendkeys can manipulate the VBA editor
if you really wanted to.
This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store
to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.