Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    close all wbook ... (2000)

    Admit i have opened various wbook in the same seesion of excel.
    I have a particular wbook.
    In this particular wbook, in event wbook open, is possible to close all actually wbook opened and start my paricular wbook?
    Naturally if in excel session not are present other wbook skip this operation....

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: close all wbook ... (2000)

    You could do something like this in the ThisWorkbook module of your workbook:

    Private Sub Workbook_Open()
    Dim i As Integer
    For i = Workbooks.Count To 1 Step -1
    If Not Workbooks(i).Name = Me.Name Then
    Workbooks(i).Close
    End If
    Next i
    End Sub

    Warning 1: if this workbook is to be used by others, they may not like it if you close other workbooks they have opened!
    Warning 2: if you have a personal macro workbook, you may want not want to close it; you'd have to add a check for that.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: close all wbook ... (2000)

    Good code and good Note/explain.
    Sal.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •