+ Reply to Thread
Results 1 to 2 of 2

Closing a Workbook

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Closing a Workbook

    Hi!
    If I have a drawn button and assign a macro that looks like this:
    [Begin Code]
    Sub ExitWarrantybook()
    Application.ScreenUpdating = False
    ActiveWorkbook.Save
    Sheets("Home Page").Select
    Range("H26").Select
    Selection.ClearContents
    ActiveWorkbook.Close
    ActiveWorkbook.Saved = True
    Application.ScreenUpdating = True
    End Sub
    [end Code]
    And I have code in the "ThisWorkbook" section that looks like this:
    [begin code]
    Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.ScreenUpdating = False
    ActiveWorkbook.Save
    ActiveWorkbook.Saved = True
    With ActiveWindow
    .DisplayHeadings = True
    .DisplayOutline = True
    .DisplayWorkbookTabs = True
    End With
    Application.ScreenUpdating = True
    End Sub
    [end code]
    Do both sets of code run before the workbook closes?

  2. #2
    Registered User
    Join Date
    07-25-2005
    Posts
    62
    I think your problem is not that they are not running, but that you save the workbook before selecting the "Home Page" and all that. Try moving the ActiveWorkbook.Save line to after those modification lines. (also it may be safer to use ThisWorkbook instead of ActiveWorkbook, it's not quite clear what you are trying to do).

    Szalapski

+ 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