+ Reply to Thread
Results 1 to 5 of 5

Close application if...

Hybrid View

  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Maba,

    If I understand your post, you want to check if there are any other open workbooks when you close the workbook you have open.

    Sub CheckForOpenWorkbooks()
      Dim Msg As String
      Dim MyWkb As String
      Dim N As Long
      Dim Wkb As Workbook
      
        MyWkb = ActiveWorkbook.Name
       
        For Each Wkb In ThisWorkbook.Workbooks
           If Wkb.Name <> MyWkb Then
              N = N + 1
              Msg = Msg & Wkb.Name & vbCrLf
           End If
        Next Wkb
       
        If N <> 0 Then
           MsgBox Str(N) & " Workbooks found Open." & vbCrLf & Msg
        End If
    
    End Sub
    This macro will check if anyother workbooks other than yours are still open and list them in a message box.

    Sincerely,
    Leith Ross

  2. #2
    Registered User
    Join Date
    08-17-2005
    Posts
    7
    Quote Originally Posted by Leith Ross
    Hello Maba,

    If I understand your post, you want to check if there are any other open workbooks when you close the workbook you have open.
    Sub CheckForOpenWorkbooks()
     Msg As String
      Dim MyWkb As 
      DimString
      Dim N As Long
      Dim Wkb As Workbook
      
        MyWkb = ActiveWorkbook.Name
       
        For Each Wkb In ThisWorkbook.Workbooks
           If Wkb.Name <> MyWkb Then
              N = N + 1
              Msg = Msg & Wkb.Name & vbCrLf
           End If
        Next Wkb
       
        If N <> 0 Then
           MsgBox Str(N) & " Workbooks found Open." & vbCrLf & Msg
        End If
    
    End Sub
    This macro will check if anyother workbooks other than yours are still open and list them in a message box.

    Sincerely,
    Leith Ross
    Thanks Leith,

    That looks exactly what I need, I just have to check that is working.

    BR
    maba

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1