+ Reply to Thread
Results 1 to 3 of 3

Workbook BeforeClose Question

Hybrid View

  1. #1
    Registered User
    Join Date
    11-21-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Workbook BeforeClose Question

    Hi,

    Just a general question. I have an add on which allows users to document a workbooks content, purpose etc. I'd like to set a message box to show if the user hasn't performed the documenting therefore I would anticipate using the following code:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    If Not SheetExists("MySheet") Then
    Msgbox "Please Document the Spreadsheet Contents
    End If

    End Sub
    My question is, how do I get the code to run when a workbook closes given that the add on will be running with lots of new workbooks.

    Thanks for your help in advance

    M

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Workbook BeforeClose Question

    Where is MySheet? Your code will only work if it's in the workbook that contains the close event code
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    11-21-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Workbook BeforeClose Question

    Quote Originally Posted by royUK View Post
    Where is MySheet? Your code will only work if it's in the workbook that contains the close event code
    Hi Roy,

    Yes that's my problem, the MySheet will be in the target workbook. I need to place the code in the target workbook somehow. This is the bit I'm struggling with

    Cheers

    Mike

+ Reply to Thread

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