Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to figure out a way to close all duplicate windows of
workbooks using VBA I thought this would work but it doesn't. For Each wb In Workbooks If Windows.Count 1 Then For i = 1 To Windows.Count Windows(2).Close Next i End If Next wb For example: I have 3 workbooks wb1, wb2, wb3 and with wb3 I have 2 windows open so there are acutally 4 windows total. wb1, wb2, wb3:1, wb3:2 I only want to close wb3:2. And would prefer to do it without having to actually activate each workbook. Any help is greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe...
Dim iCtr As Long Dim wb As Workbook For Each wb In Application.Workbooks For iCtr = wb.Windows.Count To 2 Step -1 wb.Windows(iCtr).Close Next iCtr Next wb wrote: I am trying to figure out a way to close all duplicate windows of workbooks using VBA I thought this would work but it doesn't. For Each wb In Workbooks If Windows.Count 1 Then For i = 1 To Windows.Count Windows(2).Close Next i End If Next wb For example: I have 3 workbooks wb1, wb2, wb3 and with wb3 I have 2 windows open so there are acutally 4 windows total. wb1, wb2, wb3:1, wb3:2 I only want to close wb3:2. And would prefer to do it without having to actually activate each workbook. Any help is greatly appreciated. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worked great - thanks for the help.
Dave Peterson wrote: Maybe... Dim iCtr As Long Dim wb As Workbook For Each wb In Application.Workbooks For iCtr = wb.Windows.Count To 2 Step -1 wb.Windows(iCtr).Close Next iCtr Next wb wrote: I am trying to figure out a way to close all duplicate windows of workbooks using VBA I thought this would work but it doesn't. For Each wb In Workbooks If Windows.Count 1 Then For i = 1 To Windows.Count Windows(2).Close Next i End If Next wb For example: I have 3 workbooks wb1, wb2, wb3 and with wb3 I have 2 windows open so there are acutally 4 windows total. wb1, wb2, wb3:1, wb3:2 I only want to close wb3:2. And would prefer to do it without having to actually activate each workbook. Any help is greatly appreciated. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Close Windows Media Player | Excel Discussion (Misc queries) | |||
Disable Close all Windows | Excel Discussion (Misc queries) | |||
Pop-up windows upon save &/or close | Links and Linking in Excel | |||
Is there a quick way to delete all duplicate rows in a column? | Excel Discussion (Misc queries) | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel |