Share via

Print Preview without BeforePrint

Anonymous
2013-01-28T07:31:04+00:00

Excel 2007

I have some "BeforePrint" code that saves the workbook before printing.

I would like to be able to see a Print Preview without running the BeforePrint event code.

ie, I want the code to run before printing, not before print previewing.

Is this possible?

Thanks in advance.

Dave

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. Anonymous
    2013-01-28T12:36:05+00:00

    I added your macro to a workbook. When I used PrintPreview from QAT the message box did not fire; onl;y when within Print Preview when I hit the Print button.

    The QAT Print Preview icon looks like piece of paper with magnifying glass over it.

    best wishes

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-01-28T09:31:00+00:00

    Ok thanks.

    Here's my code (without Dims).

    Private Sub Workbook_BeforePrint(Cancel As Boolean)

    msg = "The Form will be saved before being printed." & vbNewLine & vbNewLine

    msg = msg & "Proceed?"

    Title = "Print Form"

    A = MsgBox(msg, vbYesNo, Title)

    If A = vbNo Then Cancel = True: Exit Sub

    Call SaveForm

    End Sub

    This code runs when a print preview is requested, but I don't want it to - only when an actual print is requested.

    Regards - Dave.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-01-28T08:46:01+00:00

    Hi Vijay,

    Thanks for the reply. I've tried this, but Ctrl+F2 seems to qualify as a BeforePrint event

    Dave.

    Then you have to provide code here, then only someone from this forum can suggest little change to the code, as I am not so good in coding :-)

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-01-28T08:32:22+00:00

    Hi Vijay,

    Thanks for the reply. I've tried this, but Ctrl+F2 seems to qualify as a BeforePrint event

    Dave.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2013-01-28T08:18:10+00:00

    Just enter Ctrl+F2 (Print Preview) and it will show the print preview, once you are ok then give print command, so your code will work before printing and at the same time you are able to see the print preview.

    Was this answer helpful?

    0 comments No comments