+ Reply to Thread
Results 1 to 3 of 3

Beforeclose problem

  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Australia
    MS-Off Ver
    Excel 2002
    Posts
    14

    Beforeclose problem

    I have a macro that runs before close. It updates a couple of cell values. It works fine unless I have another workbook open and attempt to close all documents by closing excel. I get an out of range error because there is no sheet of the name in the other document I have open.

    Basically it seems that the beforeclose works on the active workbook, not the workbook it is saved in. I don't want to hard code the workbook filename in as I will be creating dozens of duplicates for individual users.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Beforeclose problem

    Perhaps you could post the code.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Beforeclose problem

    If you want the code to work on the workbook containing the code, use ThisWorkbook to refer to the workbook. The name of the file won't matter.
    Remember what the dormouse said
    Feed your head

+ 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