Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA print preview hangs Excel

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?



  #2   Report Post  
Posted to microsoft.public.excel.programming
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?





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA print preview hangs Excel

I tried "me.hide" before, but it hid the whole worksheet! Not good.

I also tried <formname.visible = False, but that was disallowed.

But I tried me.hide again, and this time it worked. Don't ask me why,
because I thought I did it that way last time.

But whatever, now it's ok. Thanks for the help.




"Chip Pearson" wrote in message
...
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?







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA print preview hangs Excel

I tried "me.hide" before, but it hid the whole worksheet! Not good.

If that is the case, then the code wasn't in the object module I assumed it
was. I assumed that you were calling PrintPreview directly from within a
UserForm module. In that case, "Me" refers to the UserForm object. If you
have the code in another object module, such as a worksheet module, the "Me"
reference will refer to that sheet. "Me" always refers to the instance of
the class in which it is used. Thus, if your code is in a sheet module,
you'd need to use "<form-instance-name.Hide" where <form-instance-name is
the name of your userform, or, perhaps, an instance of the form, if you have
a variable declared As UserFormName.

Hide the UserForm and PrintPreview will work as you would expect.


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


"Paul Pedersen" wrote in message
...
I tried "me.hide" before, but it hid the whole worksheet! Not good.

I also tried <formname.visible = False, but that was disallowed.

But I tried me.hide again, and this time it worked. Don't ask me why,
because I thought I did it that way last time.

But whatever, now it's ok. Thanks for the help.




"Chip Pearson" wrote in message
...
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?








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save as PDF not same size as Print and Print Preview in Excel Jack_Sprat Excel Discussion (Misc queries) 4 April 13th 09 06:38 PM
First page of Excel sheerepeats in print layout or print preview philfrotonda Excel Discussion (Misc queries) 1 July 12th 07 09:28 PM
my Excel chart doesn't print as it appears on print preview Doug 1014 Excel Discussion (Misc queries) 2 November 7th 05 09:00 AM
Why does macro speed slow after Excel Print or Print Preview? Larry A[_3_] Excel Programming 6 May 16th 05 11:22 AM
Print Preview hangs James Cooke Excel Programming 2 August 29th 03 07:26 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"