Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How many sheets open?

The Workbook has several pages including "Pages" and Specs"



At any time several could be open and selected and it is necessary to get
back to a particular arrangement. I have not checked but I imagine "Custom
views." are saved in the computer whereas this worksheet will be used on
different computers.



It would be helpful to run a macro which would make sure two specific sheets
were open arranged vertically and one a specific sheet selected. The
following is ok if there was only one sheet open at the start. How do I
reduce the open sheets to only one as the first part of the macro?



Sub SpecsPageOrder()

Sheets("Specs").Select

ActiveWindow.NewWindow

Sheets("Pages").Select

ActiveWindow.Zoom = 75

Windows.Arrange ArrangeStyle:=xlVertical

Windows("Door schedule.xls:1").Activate

ActiveWindow.Zoom = 75

End Sub



Many thanks.



Francis Hookham


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How many sheets open?

Francis,
Worksheets are not "open" in that sense; I believe you want look into the
Windows collection of the workbook.

There is also the CustomViews property of the workbook.

Recording a macro whilst you play with these will give you an idea of the
necessary code:
WindowNew Window, WindowArrange..
ViewCustom Views...

I'm exactly sure from your question if want multiple windows or not
though....

NickHK

"Francis Hookham" wrote in message
...
The Workbook has several pages including "Pages" and Specs"



At any time several could be open and selected and it is necessary to get
back to a particular arrangement. I have not checked but I imagine "Custom
views." are saved in the computer whereas this worksheet will be used on
different computers.



It would be helpful to run a macro which would make sure two specific

sheets
were open arranged vertically and one a specific sheet selected. The
following is ok if there was only one sheet open at the start. How do I
reduce the open sheets to only one as the first part of the macro?



Sub SpecsPageOrder()

Sheets("Specs").Select

ActiveWindow.NewWindow

Sheets("Pages").Select

ActiveWindow.Zoom = 75

Windows.Arrange ArrangeStyle:=xlVertical

Windows("Door schedule.xls:1").Activate

ActiveWindow.Zoom = 75

End Sub



Many thanks.



Francis Hookham




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How many sheets open?

Sorry Nick - I did not make myself clear - I had developed the macro from a
recording but it depends on there being only one sheet (window) being open
at the start - any sheet (window), but only one.

What I am looking for is a bit of code which will close all but one sheet
(window). Will there have to be an error handler for when there is anyway
only one sheet (window) open?

I realise we are anyway talking about only one workbook being open.

I hope you can help with that.

Francis

"NickHK" wrote in message
...
Francis,
Worksheets are not "open" in that sense; I believe you want look into the
Windows collection of the workbook.

There is also the CustomViews property of the workbook.

Recording a macro whilst you play with these will give you an idea of the
necessary code:
WindowNew Window, WindowArrange..
ViewCustom Views...

I'm exactly sure from your question if want multiple windows or not
though....

NickHK

"Francis Hookham" wrote in message
...
The Workbook has several pages including "Pages" and Specs"



At any time several could be open and selected and it is necessary to get
back to a particular arrangement. I have not checked but I imagine
"Custom
views." are saved in the computer whereas this worksheet will be used on
different computers.



It would be helpful to run a macro which would make sure two specific

sheets
were open arranged vertically and one a specific sheet selected. The
following is ok if there was only one sheet open at the start. How do I
reduce the open sheets to only one as the first part of the macro?



Sub SpecsPageOrder()

Sheets("Specs").Select

ActiveWindow.NewWindow

Sheets("Pages").Select

ActiveWindow.Zoom = 75

Windows.Arrange ArrangeStyle:=xlVertical

Windows("Door schedule.xls:1").Activate

ActiveWindow.Zoom = 75

End Sub



Many thanks.



Francis Hookham






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How many sheets open?

Got it - should not have had to bother you (unless there is a less crude
way):

Sub Pages_SPECS_Order()
Application.ScreenUpdating = False
'This will make sure only two windows are open
'arranged vertically - Pages and SPECS, Specs being selected
On Error Resume Next
Windows("Door schedule.xls:3").Activate
On Error Resume Next
Windows("Door schedule.xls:3").Close
On Error Resume Next
Windows("Door schedule.xls:2").Activate
On Error Resume Next
Windows("Door schedule.xls:2").Close
Sheets("Pages").Select
ActiveWindow.NewWindow
Sheets("Pages").Select
ActiveWindow.Zoom = 75
Windows.Arrange ArrangeStyle:=xlVertical
Windows("Door schedule.xls:1").Activate
ActiveWindow.Zoom = 75
End Sub

Francis

"NickHK" wrote in message
...
Francis,
Worksheets are not "open" in that sense; I believe you want look into the
Windows collection of the workbook.

There is also the CustomViews property of the workbook.

Recording a macro whilst you play with these will give you an idea of the
necessary code:
WindowNew Window, WindowArrange..
ViewCustom Views...

I'm exactly sure from your question if want multiple windows or not
though....

NickHK

"Francis Hookham" wrote in message
...
The Workbook has several pages including "Pages" and Specs"



At any time several could be open and selected and it is necessary to get
back to a particular arrangement. I have not checked but I imagine
"Custom
views." are saved in the computer whereas this worksheet will be used on
different computers.



It would be helpful to run a macro which would make sure two specific

sheets
were open arranged vertically and one a specific sheet selected. The
following is ok if there was only one sheet open at the start. How do I
reduce the open sheets to only one as the first part of the macro?



Sub SpecsPageOrder()

Sheets("Specs").Select

ActiveWindow.NewWindow

Sheets("Pages").Select

ActiveWindow.Zoom = 75

Windows.Arrange ArrangeStyle:=xlVertical

Windows("Door schedule.xls:1").Activate

ActiveWindow.Zoom = 75

End Sub



Many thanks.



Francis Hookham






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How many sheets open?

Ah! That's what I wanted - neat, not pedestian like mine.

Many thanks Nick

Francis


"NickHK" wrote in message
...
Francis,
Avoid the guesswork and use the Windows collection:

Private Sub CommandButton1_Click()
Dim win As Window

With ThisWorkbook
For Each win In .Windows
If .Windows.Count 1 Then win.Close
Next
End With
End Sub

NickHK

"Francis Hookham" wrote in message
...
Got it - should not have had to bother you (unless there is a less crude
way):

Sub Pages_SPECS_Order()
Application.ScreenUpdating = False
'This will make sure only two windows are open
'arranged vertically - Pages and SPECS, Specs being selected
On Error Resume Next
Windows("Door schedule.xls:3").Activate
On Error Resume Next
Windows("Door schedule.xls:3").Close
On Error Resume Next
Windows("Door schedule.xls:2").Activate
On Error Resume Next
Windows("Door schedule.xls:2").Close
Sheets("Pages").Select
ActiveWindow.NewWindow
Sheets("Pages").Select
ActiveWindow.Zoom = 75
Windows.Arrange ArrangeStyle:=xlVertical
Windows("Door schedule.xls:1").Activate
ActiveWindow.Zoom = 75
End Sub

Francis

"NickHK" wrote in message
...
Francis,
Worksheets are not "open" in that sense; I believe you want look into

the
Windows collection of the workbook.

There is also the CustomViews property of the workbook.

Recording a macro whilst you play with these will give you an idea of

the
necessary code:
WindowNew Window, WindowArrange..
ViewCustom Views...

I'm exactly sure from your question if want multiple windows or not
though....

NickHK

"Francis Hookham" wrote in message
...
The Workbook has several pages including "Pages" and Specs"



At any time several could be open and selected and it is necessary to

get
back to a particular arrangement. I have not checked but I imagine
"Custom
views." are saved in the computer whereas this worksheet will be used

on
different computers.



It would be helpful to run a macro which would make sure two specific
sheets
were open arranged vertically and one a specific sheet selected. The
following is ok if there was only one sheet open at the start. How do
I
reduce the open sheets to only one as the first part of the macro?



Sub SpecsPageOrder()

Sheets("Specs").Select

ActiveWindow.NewWindow

Sheets("Pages").Select

ActiveWindow.Zoom = 75

Windows.Arrange ArrangeStyle:=xlVertical

Windows("Door schedule.xls:1").Activate

ActiveWindow.Zoom = 75

End Sub



Many thanks.



Francis Hookham












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
open workbook, display certain sheets [email protected] Excel Programming 1 March 9th 07 07:08 AM
When I open a file in excel, I cannot open any of the sheets Barb Excel Worksheet Functions 0 October 30th 06 11:08 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Can't open protected sheets Laurent Imbault Setting up and Configuration of Excel 2 January 14th 05 03:07 PM
Can't open protected sheets Laurent Imbault Excel Programming 2 January 13th 05 05:05 PM


All times are GMT +1. The time now is 07:18 PM.

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"