PDA

View Full Version : Excel Question



Peter Stahl
11-10-2009, 8:49 AM
Is there a way to use a print command in a Macro with a specific printer. Usually the one that is the default isn't the one needed.

Prashun Patel
11-10-2009, 9:10 AM
I think you have to use the Application.ActivePrinter method.

I found this on the web; can't take credit:

---
'Store default printer name
Dim defaultPrinterAs String
defaultPrinter = Application.ActivePrinter

'Change Printer name
Application.ActivePrinter = "<desired printer name>"
ActiveSheet.PrintOut

'Reset printer to default
Application.ActivePrinter = defaultPrinter
---

FWIW, when I can't figure out the method in an excel macro, I just 'record' a new macro and then use the mouse to do the work. When you hit the stop button, excel creates a new vba module with all the code in it.

Peter Stahl
11-10-2009, 5:02 PM
thanks Shawn but it didn't work. I'll try it again when i get a chance.

Todd Willhoit
11-10-2009, 10:40 PM
Try this:

Answer = Application.Dialogs(xlDialogPrinterSetup).Show
If Answer = False Then Exit Sub
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Todd

Peter Stahl
11-11-2009, 8:18 PM
I tried using the record Macro method on my work PC but it didn't give me what I was looking for. I used my old desktop PC with Excel 2000 on it and I got what I was looking for. It gave me the printer name I need and used a version of what Shawn posted above. Thanks for all the help!

Joe Pelonio
11-11-2009, 10:11 PM
I have some on files I use at work but they are Office 2007. Today I had to come up with a formula to add a column but only for those rows where a certain row in another table had a certain value. Took ages to figure out but I got it. Sometimes it helps to google your question, lots of websites to help with Excel.

Peter Stahl
11-12-2009, 7:21 AM
You're right Joe, that also helped get the answers I needed but the people here are also so much more helpful. When I searched first it didn't help much after getting a couple replies it helped me google and get a better answer with what I got here did what I wanted to be able to do. I used to write some Macros and it always took many tries for me to get exactly what I wanted. For someone who programs all the time excel macros are probably not a big deal. Do you have any good web sites that you use the most?

Joe Pelonio
11-12-2009, 8:10 AM
Do you have any good web sites that you use the most?
Actually "www dot my daughter" is the best source for me, she works as a research analyst and knows excel very well. :D Actually I just call or email her.

There's mrexcel which charges for fast answers but slow ones are free. I have used excel dot tips dot net, and sometimes even the MS page helps, it's at office dot microsoft dot com, then clip "help & how-to".

Prashun Patel
11-12-2009, 9:08 AM
I do a decent amount of 'programming' in VBA/excel macros for my company. It's a cheap and surprisingly versatile way to make fairly powerful applications for low-volume usage...

If you need any info, just pm me.

Peter Stahl
11-12-2009, 9:18 AM
thanks again Joe and Shawn for the info.