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
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