View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default 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?