Results 1 to 13 of 13

Error when closing multiple workbooks using the beforeclose() sub

Threaded View

  1. #1
    Registered User
    Join Date
    07-22-2011
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    20

    Error when closing multiple workbooks using the beforeclose() sub

    The maro that runs in one sheet returns it to a base operating state and clears all the data. This works fine... But The problem is the user may have multiple open windows, and when Excel is exited it tries to close all the windows. If the workbook that contains the beforeclose() sub routine isnt active i get subscript errors. Now it gets better I come in this morning and I am no longer gettting the errors but when I close the sheet it will switch to the workbook containg the subroutine and then you have to exit excel again in order for the workbooks to actually close. How do i fix this so excel will close like normal and not be required to close twice?

    This is what i have so far. the before close just call this macro. Mybook and pass code are Dim at the top as strings. Also if these two are declared in this module would the interact with other modules? or other modules in other workbooks?

        Windows(mybook).Activate
        If access_features = 1 Then
            Sheets("features").Activate
            Cells(17, 6) = ""
            Cells(17, 11) = ""
            Sheets("Features").Visible = False
        End If
        Sheets("welcome").Activate
        Cells(31, 9) = ""
        ActiveWorkbook.Protect Password:=passcode, Structure:=True, Windows:=False
        access_features = 0
        ActiveWorkbook.Save
    thanks for yalls help
    Last edited by alexthapyro; 07-25-2011 at 09:33 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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