View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VBA print preview hangs Excel

Paul,

You MUST Hide your form prior to calling PrintPreview and then Show the form
after PrintPreview is closed. PrintPreview acts modally, so your code will
pause execution until Preview is closed. E.g.,

Private Sub btnPrintPreview_Click()
Me.Hide
Worksheets(1).PrintPreview
Me.Show
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Paul Pedersen" wrote in message
...
I'm using Excel 2003 SP2.

I have a non-modal form that has among other things, a button that when
clicked has this code:

Worksheets(<sheet name).PrintPreview

When I click on this button, the print preview appears as expected, but
Excel hangs completely. Any click on the Excel window or the VB editor
window or the form results in just a beep. It almost acts as if there were
a modal window open, but there is none. I can no longer alt-tab to either
Excel or the VB editor. I have to kill it with the Task Manager.

What am I doing wrong?