View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Change view without activating sheet?

In the big scheme of things it's not that much work -

Sub test()
Dim i As Long
Dim shtOrig As Object

ReDim bArr(1 To Worksheets.Count) As Boolean
Set shtOrig = ActiveSheet

Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
Worksheets(i).Select
If ActiveWindow.View = xlPageBreakPreview Then
ActiveWindow.View = xlNormalView
bArr(i) = True
End If
Next
shtOrig.Select
Application.ScreenUpdating = True


' Do stuff

Stop ' have a look

Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
If bArr(i) = True Then
Worksheets(i).Select
ActiveWindow.View = xlPageBreakPreview
End If
Next
shtOrig.Select
Application.ScreenUpdating = True

End Sub

Regards,
Peter T

"michael.beckinsale" wrote in message
...
Hi Peter,

I was afraid that was the response l was going to get.

I have taken your suggestion on board and created loops to set the
worksheet views, store in an array, and then restore views
accordingly.

It seems a disproportionate amount of work to simply set the view but
l suppose thats Microsoft / VBA !

Thanks very much for your kind help over the past couple of days.

Regards

Michael