Generalize sub to work on all open books and views

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

How could the sub below be generalized to work on all simultaneously open
books and views (I may have some books open with multiple windows)? The sub
currently works only on the activebook/view (where the cursor is). Thanks

Sub NoGridLinesZoom75()
Dim ws As Worksheet
Dim wsht As Worksheet
Set wsht = ActiveSheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
Next
wsht.Select
End Sub
 
Sub NoGridLinesZoom75()
Dim ws As Worksheet
Dim wsht As Worksheet dim wb as workbook
Set wsht = wb.ActiveSheet
for each wb in workbooks
wb.activate
For Each ws In wb.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
Next
wsht.Select
next
End Sub
 
Hi

Try this:

Sub NoGridLinesZoom75()
Dim wbk As Workbook
Dim ws As Worksheet
Dim wsht As Worksheet
Application.ScreenUpdating = False
Set wsht = ActiveWorkbook.ActiveSheet
For Each wbk In Application.Workbooks
For Each ws In wbk.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
Next
Next
wsht.Select
Application.ScreenUpdating = True
End Sub

Regards,
Per
 
The sub halted here when I tried it:Runtime error 91, object variable or with block variable not set
 
Back
Top