hi
got stuck on this one - macro is not exiting from print preview mode
please help me if you know the VBA code so it can close the print preview mode (preferably not "private sub" code)
thanks in advance
hi
got stuck on this one - macro is not exiting from print preview mode
please help me if you know the VBA code so it can close the print preview mode (preferably not "private sub" code)
thanks in advance
Last edited by yeoye; 03-24-2009 at 06:13 AM.
I don't know if you can. Print Preview is modal -- code suspends until you close it.
Entia non sunt multiplicanda sine necessitate
ok, the answer seems very simple
as the code was written via using record macro command as suppose to writing code in vba module directly, when the macro is run, by default it stops at print preview screen without closing the screen due to this code:
ActiveWindow.SelectedSheets.PrintPreview
I had to disable this code by putting an apostrophe in front of it and disable it
to make it look like this:
'ActiveWindow.SelectedSheets.PrintPreview
In other words macro runs as usual, adjusting required margins etc, and skips print preview mode.
The final code is given below for those who want to adjust print margins, landscape print setup, insert footer and other options in print preview mode but without actually being stuck on print preview screen, halting the macro continuing executing rest of the code.
Please Login or Register to view this content.
I was very surprised not finding any suitable material in all excel related forums I could find in google over the past 2 days
Last edited by dominicb; 03-24-2009 at 07:06 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks