1
votes

In Excel 2013, Excel likes to remember Excel windows (not worksheets) that were open, and when the workbook is opened again, also open up those windows:

From user interface: With a new workbook, Ribbon Tab "View" and then "New Window". Now two windows are open. Edit at will. Save the WorkBook. Then when that workbook is opened again, both windows are opened.

I'd like to prevent this this programatically within VBA, as part of WorkBook_Open I suppose, so that just one window would open. How can I do that? I've tried closing all windows using WorkBook_Close, that didn't work.

1

1 Answers

1
votes

Just loop through the Windows collection and close them until you only have one open:

Private Sub Workbook_Open()

    Do While Me.Windows.Count > 1
        Me.Windows(1).Close
    Loop

End Sub