Note: Excel 2003 and XP operating system.
Hello All,
I had an issue with trying to identify/count how many windows I have open for a particular workbook in VBA.
Then as I was typing it in here I worked it out. So I thought I might post it as a hint to see what you People think.
If for example I have two files open and three windows
( "TheFile.XLS" ,"TheOtherFile.XLS:1", "TheOtherFile.XLS:2")
I may need to identify and manipulate the "excess" windows before I can continue.
In this example I close them off so I can then refer to just a single window, Windows(TheFileName) from then on.
TheFileName = “TheOtherFile.XLS”
If Workbooks(TheFileName).Windows.Count > 1 Then
Do While Workbooks(TheFileName).Windows.Count > 1
Application.Windows(TheFileName& ":2").Close
Loop
End If
Any Comments are welcome - and thanks for the prompt help I have got from you all over the years.
Lea.
Hello All,
I had an issue with trying to identify/count how many windows I have open for a particular workbook in VBA.
Then as I was typing it in here I worked it out. So I thought I might post it as a hint to see what you People think.
If for example I have two files open and three windows
( "TheFile.XLS" ,"TheOtherFile.XLS:1", "TheOtherFile.XLS:2")
I may need to identify and manipulate the "excess" windows before I can continue.
In this example I close them off so I can then refer to just a single window, Windows(TheFileName) from then on.
TheFileName = “TheOtherFile.XLS”
If Workbooks(TheFileName).Windows.Count > 1 Then
Do While Workbooks(TheFileName).Windows.Count > 1
Application.Windows(TheFileName& ":2").Close
Loop
End If
Any Comments are welcome - and thanks for the prompt help I have got from you all over the years.
Lea.