Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Differentiate between 'Print' and 'Print Preview' in VBA code
Hello,
I have set up some code in a Workbook_BeforePrint Sub to log information as worksheets are printed. That is, for example, I have sheetA, sheetB, and sheetLog, and whenever a user prints either sheetA or sheetB, my code will take some information (e.g., name and date) from that sheet and copy it to sheetLog. The issue I have now discovered is that the information will also be logged if the user merely executes a Print Preview, which makes sense to me. I am wondering, though, if there is a way to differentiate, in the code, between an actual 'Print' and just a 'Print Preview'. I am envisioning something like: If <just Print Preview Then <don't log information Else 'actually Printing <do stuff as normal End If Does such a distinction between 'Print' and 'Print Preview' exist? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Differentiate between 'Print' and 'Print Preview' in VBA code
Mattantaliss,
I googled this and the answer seems to be "no." Here's Chip Pearson a year ago in response to a question pretty much identical to yours: "The BeforePrint is rather anemic; it doesn't tell you what is being printed (a range, a sheet, or a workbook) and doesn't distinguish between printing and print preview. I don't think there is any solid way to do what you want." You could always query the user inside the BeforePrint event as to what they're doing, I guess, but that sounds annoying. hth, Doug "Mattantaliss" wrote in message ... Hello, I have set up some code in a Workbook_BeforePrint Sub to log information as worksheets are printed. That is, for example, I have sheetA, sheetB, and sheetLog, and whenever a user prints either sheetA or sheetB, my code will take some information (e.g., name and date) from that sheet and copy it to sheetLog. The issue I have now discovered is that the information will also be logged if the user merely executes a Print Preview, which makes sense to me. I am wondering, though, if there is a way to differentiate, in the code, between an actual 'Print' and just a 'Print Preview'. I am envisioning something like: If <just Print Preview Then <don't log information Else 'actually Printing <do stuff as normal End If Does such a distinction between 'Print' and 'Print Preview' exist? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Differentiate between 'Print' and 'Print Preview' in VBA code
Hi Doug,
Thanks for the information. I too had googled this question, but just wasn't having any luck with it (and definitely hadn't stumbled across Chip's response). I think, in this instance, Print Preview won't be used too often, if ever; and instead of slowing things down with a dialog to respond to, I'll just let the co-worker I am writing this for know about how it acts so she may go back and delete any logged information from a Print Preview. Thanks again... that does help. matt "Doug Glancy" wrote: Mattantaliss, I googled this and the answer seems to be "no." Here's Chip Pearson a year ago in response to a question pretty much identical to yours: "The BeforePrint is rather anemic; it doesn't tell you what is being printed (a range, a sheet, or a workbook) and doesn't distinguish between printing and print preview. I don't think there is any solid way to do what you want." You could always query the user inside the BeforePrint event as to what they're doing, I guess, but that sounds annoying. hth, Doug "Mattantaliss" wrote in message ... Hello, I have set up some code in a Workbook_BeforePrint Sub to log information as worksheets are printed. That is, for example, I have sheetA, sheetB, and sheetLog, and whenever a user prints either sheetA or sheetB, my code will take some information (e.g., name and date) from that sheet and copy it to sheetLog. The issue I have now discovered is that the information will also be logged if the user merely executes a Print Preview, which makes sense to me. I am wondering, though, if there is a way to differentiate, in the code, between an actual 'Print' and just a 'Print Preview'. I am envisioning something like: If <just Print Preview Then <don't log information Else 'actually Printing <do stuff as normal End If Does such a distinction between 'Print' and 'Print Preview' exist? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Differentiate between 'Print' and 'Print Preview' in VBA code
You might find this interesting! I placed some code to display a message in
the Before_Print event and ran PrintPreview. The message displayed, the PrintPreview window opened, I closed it, the message displayed again, then the sheet printed. Now, ..what's up with that? FWIW Garry |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Differentiate between 'Print' and 'Print Preview' in VBA code
Hello,
As a follow-up on this, I got to thinking that if I am unable to tell the difference between a 'Print' and a 'Print Preview', I might be able to just tell when the 'Print Preview' window has closed and then undo any logging that had occurred when it was brought up. Would it be possible to know when that window has closed to have some code undo the logging that had been done? I'm picturing something like: <onPrintPreviewClose <delete row(s) of logged info |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Print and Print Preview Graphic Moving Resizing 2007/2003 | Excel Discussion (Misc queries) | |||
cell borders that I create dont show on print preview or print | Excel Discussion (Misc queries) | |||
Code before Print but not Print Preview | Excel Programming | |||
Why does macro speed slow after Excel Print or Print Preview? | Excel Programming | |||
Resuming code after closing a print preview | Excel Programming |