View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Help with a quick way to close all duplicate windows using VBAplease

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