+ Reply to Thread
Results 1 to 3 of 3

Working with WorkBook Close event and Personal.xlsb files

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Working with WorkBook Close event and Personal.xlsb files

    If Workbooks.Count <2 Then Application.Quit Else ActiveWorkbook.Close
    I have noticed that when i have added some VBA to my Personal file, that the above code when run now does not work as it view the Personal file as another workbook.

    But if I simply change (<2) to (<3) then other users whoi dod not have a personal file may have other excel workbooks closed on them without wanting.


    Is there a simply way around this?

    Is there a line i can use to establish if the other WorkBook name is the Personal file?
    Last edited by coreytroy; 04-08-2013 at 11:35 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Working with WorkBook Close event and Personal.xlsb files

    Hi, coreytroy,

    you might take into consideration that there is both a personl.xls and a personal.xlsb available for a user:
    Sub sample()
    Dim wb As Workbook
    Dim lngPers As Long
    For Each wb In Workbooks
      If UCase(wb.Name) = "PERSONAL.XLSB" Then lngPers = 1
    Next wb
    If Workbooks.Count < 2 + lngPers Then
      Application.Quit
    Else
      ActiveWorkbook.Close
    End If
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Working with WorkBook Close event and Personal.xlsb files

    Thanks HaHoBe.

+ 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