Print workbook without opening it

B

Brettjg

How can I print a workbook from a macro without opening the workbook?
Regards, Brett
 
J

JLatham

Can't be done.

I think the closest you could get would be to initially use Print to File
option in Excel's File | Print dialog and then use VB to print that file (an
interesting exercise in itself these days) but the output file would be
printer dependent because the control codes for the printer are embedded
within the output file, I believe. That would mean if you used the drivers
for the printer on your computer, someone else with a different printer would
not get same output results. If you had a non-specific printer type defined,
such as a virtual .pdf device, then you could print to that device, it would
end up in .pdf format and you may be able to direct that to any printer.
I've never attempted any of that, so haven't a clue as to whether it would
actually work or not.

Best thing to do is simply set your macro up to open the workbook - and
print it from the macro.
 
B

Brettjg

Thanks Jerry. I thought you might say that. Have already got the code in
place, but was trying to avoid a lot of dancing on the screen. Regards, Brett
 
B

Brettjg

Thanks Jon. I thought you might say that. Have already got the code in place,
but was trying to avoid a lot of dancing on the screen. Regards, Brett
 
J

Jon Peltier

Application.ScreenUpdating = False
Workbooks("abc.xls").Open
ActiveSheet.PrintOut
Application.ScreenUpdating = True

- Jon
 
B

Brettjg

Thanks Jon, actually using a version of that. There are a number of
books/sheets that get printed, and I have a sheet that keep a visual track of
the printing routine so that the user can see where it's up to. By not
updating the screen they can't see the boxes change colour etc. I guess I can
play around with turning the updating on and off at various times.

I have another question for you. In my VB editor, for the last 36 hours,
whenever I do a find and/or replace the dialogue box snaps over to the left.
This is very aggravating, and it only started doing it without me doing or
changing anything that I'm aware of. As usual I can't find anything in VB
Help (only useful for solutions to complex problems). I imagine that I'm not
alone in my opinion of VB help (the help in excel is very good, by contrast).
Thanks & regards, Brett
 
J

Jon Peltier

In my VB Editor, the Find/Replace dialog likes to pop up straddling my two
screens (the VBE is maximized on the left screen, Excel maximized on the
right). This is an enormous pain. But I generally use the Find functionality
in MZTools instead. MZTools is a free VBE add-in that has lots of useful
features. Use Google to find it.

- Jon
 
B

Brettjg

Great, thanks Jon

Jon Peltier said:
In my VB Editor, the Find/Replace dialog likes to pop up straddling my two
screens (the VBE is maximized on the left screen, Excel maximized on the
right). This is an enormous pain. But I generally use the Find functionality
in MZTools instead. MZTools is a free VBE add-in that has lots of useful
features. Use Google to find it.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______
 
Top