Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Generalize sub to work on all open books and views

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Generalize sub to work on all open books and views

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


On 17 Jul., 15:55, Max wrote:
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Generalize sub to work on all open books and views

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

"Max" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Generalize sub to work on all open books and views

The sub halted here when I tried it:
Set wsht = wb.ActiveSheet

Runtime error 91, object variable or with block variable not set


  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Generalize sub to work on all open books and views

Thanks, Per. Tried it out, and it works fine

Max


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
formula to work in a 3-d reference with 2 work books capt c Excel Worksheet Functions 1 April 8th 09 08:04 PM
need a function that will work using multiple work books and sheet capt c Excel Worksheet Functions 1 March 30th 09 10:20 PM
How to generalize sorting range in macro??? Jac Excel Programming 2 June 27th 07 07:04 PM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Work books shell4923 Excel Worksheet Functions 1 March 29th 05 04:28 PM


All times are GMT +1. The time now is 10:01 AM.

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"