#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default PrintPreview

How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default PrintPreview

maybe Sendkey the Escape key?

Gerry Verschuuren wrote:

How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default PrintPreview

No that doesn't do the job

"Bob I" wrote:

maybe Sendkey the Escape key?

Gerry Verschuuren wrote:

How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default PrintPreview

What about Alt+C ?

Gerry Verschuuren wrote:
No that doesn't do the job

"Bob I" wrote:


maybe Sendkey the Escape key?

Gerry Verschuuren wrote:


How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default PrintPreview

The problem seems to be that I use a MsgBox which shows up on the original
sheet and not on the Preview window. This is the code I am trying to run:

Sub Test()
Dim oWS As Worksheet
For Each oWS In Worksheets
oWS.PrintPreview
If MsgBox("Close?", vbYesNo) = vbYes Then SendKeys "{ESC}"
Next oWS
End Sub

"Bob I" wrote:

What about Alt+C ?

Gerry Verschuuren wrote:
No that doesn't do the job

"Bob I" wrote:


maybe Sendkey the Escape key?

Gerry Verschuuren wrote:


How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default PrintPreview

As I recall those message/dialog boxes have the focus. Until you clear
that, you can't access the window, because it doesn't have focus. In
looking at your code, I think you could dispense with
"If MsgBox("Close?", vbYesNo) = vbYes Then " and just use

SendKeys "{ESC}"


Gerry Verschuuren wrote:

The problem seems to be that I use a MsgBox which shows up on the original
sheet and not on the Preview window. This is the code I am trying to run:

Sub Test()
Dim oWS As Worksheet
For Each oWS In Worksheets
oWS.PrintPreview
If MsgBox("Close?", vbYesNo) = vbYes Then SendKeys "{ESC}"
Next oWS
End Sub

"Bob I" wrote:


What about Alt+C ?

Gerry Verschuuren wrote:

No that doesn't do the job

"Bob I" wrote:



maybe Sendkey the Escape key?

Gerry Verschuuren wrote:



How can a PrintPreview screen be close through VBA code?

Thank you in advance for your help.




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
ActiveX Controls moving upon print/printpreview Steven Cheng Excel Discussion (Misc queries) 6 February 2nd 05 03:31 AM


All times are GMT +1. The time now is 06:20 PM.

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

About Us

"It's about Microsoft Excel"