Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Workbook name

I need to activate one or other windows by switching from one to the other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Workbook name

One way:

Windows(Workbook.Name & ":1").Activate



In article ,
"Francis Hookham" wrote:

I need to activate one or other windows by switching from one to the other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Workbook name

Francis,

Sub TryNow()
Dim myW As Window

For Each myW In ActiveWorkbook.Windows
Right(myW.Caption, 2) = ":1" Then
myW.Activate
Exit Sub
End If
Next myW

End Sub

You may also want to change ActiveWorkbook to ThisWorkbook, or another Workbook object, like to

Dim myB As Workbook
Set myB = Workbooks.Open(Application.GetOpenFilename)

'Other code, then

For Each myW In myB.Windows


HTH,
Bernie
MS Excel MVP


"Francis Hookham" wrote in message
...
I need to activate one or other windows by switching from one to the other rather than by name of
sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Workbook name

Many thanks JE McG - just what I wanted

Francis


"JE McGimpsey" wrote in message
...
One way:

Windows(Workbook.Name & ":1").Activate



In article ,
"Francis Hookham" wrote:

I need to activate one or other windows by switching from one to the
other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Workbook name

Many thanks, Bernie _ I'll use McG's for now - it was what I was trying to
do - but I'll examine yours to see how it works.

Francis


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Francis,

Sub TryNow()
Dim myW As Window

For Each myW In ActiveWorkbook.Windows
Right(myW.Caption, 2) = ":1" Then
myW.Activate
Exit Sub
End If
Next myW

End Sub

You may also want to change ActiveWorkbook to ThisWorkbook, or another
Workbook object, like to

Dim myB As Workbook
Set myB = Workbooks.Open(Application.GetOpenFilename)

'Other code, then

For Each myW In myB.Windows


HTH,
Bernie
MS Excel MVP


"Francis Hookham" wrote in message
...
I need to activate one or other windows by switching from one to the other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Workbook name did not work

Oh dear! Replace has not worked - here is one of the subs. (I have included
the original lines of code as comments so you can see what did work). I hope
you can you see what is wrong.

Sub vPages_Specs()
' Display Pages and Schedule sheets vertically
Application.ScreenUpdating = False
'This will make sure only two windows are open arranged vertically
With ThisWorkbook
For Each win In .Windows
If .Windows.Count 1 Then win.Close
Next
End With
Sheets("Specs").Select
ActiveWindow.NewWindow
' Windows("DoorSchedule.xls:1").Activate
Windows(Workbook.Name & ":1").Activate
ActiveWindow.Zoom = 75
Rows("2:2").Select
ActiveWindow.FreezePanes = True
Range("C2").Select
' Windows("DoorSchedule.xls:2").Activate
Windows(Workbook.Name & ":2").Activate
Sheets("Pages").Select
ActiveWindow.Zoom = 75
Windows.Arrange ArrangeStyle:=xlVertical
' scroll to last door
iR = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row
ActiveWindow.ScrollRow = iR
Cells(iR, 3).Select
' Windows("DoorSchedule.xls:1").Activate
Windows(Workbook.Name & ":1").Activate
End Sub



"JE McGimpsey" wrote in message
...
One way:

Windows(Workbook.Name & ":1").Activate



In article ,
"Francis Hookham" wrote:

I need to activate one or other windows by switching from one to the
other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

Thanks

Francis Hookham



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Workbook name - got it at last

Got it at last:

Windows(ActiveWorkbook.Name + ":1").Activate
or
Windows(ActiveWorkbook.Name & ":1").Activate

Intreaging for an amateur that it seems to make no difference using
+ or & (plus or ampersand) !

Francis


"JE McGimpsey" wrote in message
...
One way:

Windows(Workbook.Name & ":1").Activate



In article ,
"Francis Hookham" wrote:

I need to activate one or other windows by switching from one to the
other
rather than by name of sheet:

Windows("DoorSchedule.xls:1").Activate
Windows("DoorSchedule.xls:2").Activate

but this does not work if the Workbook is renamed.

Please show me how to write something like:

Windows(Workbook.name + ".xls:1").Activate

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
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 04:22 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"