![]() |
PrintPreview
How can a PrintPreview screen be close through VBA code?
Thank you in advance for your help. |
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. |
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. |
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. |
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. |
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. |
All times are GMT +1. The time now is 10:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com