Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    closing a workbook (2000/sr-1)

    What is the code to check if other workbooks are open
    I need to write a peice of code that checks this condition and then either closes excel completely or just closes that file if others are open.

    Thanks

  2. #2
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: closing a workbook (2000/sr-1)

    if application.workbooks.count > 1 then
    msgbox "Hey there's more than one WB open"
    end if
    (the application. is optional)

    Deb

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: closing a workbook (2000/sr-1)

    The following code can be used to see if a workbook is open:

    <pre>Dim oWb As Workbook
    On Error Resume Next
    Set oWb = Workbooks("MyWorkbook.xls")
    On Error GoTo 0
    If oWb Is Nothing Then
    MsgBox "The workbook is not open."
    End If
    </pre>

    Legare Coleman

Posting Permissions

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