PDA

View Full Version : Printout error?



cmperez
07-13-2006, 07:32 PM
I have many command "print" buttons on every page of a workbook. They are invidividually set up to print a specific range. When I use this at home, it works fine, when I send it to a user at work the print functions do not work. I assume because I have a different printer at home then we do at work. Is there a way to automatically print to any computers default printer?

If there is a code that would work, where do I put it?
The print button currently is:



Private Sub CommandButton1_Click()
ActiveSheet.Range("A1:G9").PrintOut
End Sub


I have seen many examples of different codes but I am not sure on how to use them correctly.

Thanks for your help

matthewspatrick
07-13-2006, 07:45 PM
Silly question: what macro security level are you using at home, and what level are you (or your colleagues) using at work?

cmperez
07-13-2006, 07:47 PM
We are using medium security for both places. I do not have an actual printer installed at home. I generally print to pdf and email to work if I actually have to print anything. At work we have about 5 different HP printers.

matthewspatrick
07-13-2006, 07:49 PM
Always look for the easy answer first :grinhalo:

cmperez
07-13-2006, 07:52 PM
Is there something totally easy that I am missing? I have spent all day trying to make this work and it is driving me crazy.....

mdmackillop
07-13-2006, 11:33 PM
I suspect that your workbook is remembering the last printer it was printed on. As that printer is not available at the new location, the print doesn't happen. In Excel, the printer has to be set to (for want of a better name) a Port. Recording a macro shouls show something like "LaserJet on Ne01:"
I submitted this KB http://vbaexpress.com/kb/getarticle.php?kb_id=528 for changing printers in excel (It looks complicated but usage is straightforward).
You may need to add some code to determine where you are, and set the printer name accordingly.
Hopefully, there is a simpler solution!
Regards
MD