+ Reply to Thread
Results 1 to 5 of 5

Beforesave code applied to any file

  1. #1
    Registered User
    Join Date
    04-07-2013
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Beforesave code applied to any file

    Hi,

    I know how to include a beforesave code for a given file. I also know how to have my general macros always available by having them in a personal.xlsb file.
    But I want to have a beforesave macro that would run when I save any file without having to add it to each file individually. Is there a way to do that?

    Thanks

    Stéphane

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Beforesave code applied to any file

    Hi there,

    Run the following code from the Immediate Window:

    Please Login or Register  to view this content.
    It will give you a folder path similar to

    "C:\Users\UserId\AppData\Roaming\Microsoft\Excel\XLSTART"
    Insert the attached file in the folder identified above, and start Excel - this will open a hidden workbook which contains code which will be executed before any workbook is saved.

    You can insert your own code in the appropriate location in the Class Module:

    Please Login or Register  to view this content.
    Hope this helps - please let me know how you get on.

    Regards.

    Greg M
    Attached Files Attached Files

  3. #3
    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: Beforesave code applied to any file

    Another way: in the ThisWorkbook module of Personal,

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    04-07-2013
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Beforesave code applied to any file

    Thank Greg,

    It worked perfectly fine! Now I won't forget to select cell A1 of sheet1 when saving and closing a file as per our business policy.
    The request can be closed.

    Stéphane

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Beforesave code applied to any file

    Hi again Stéphane,

    Many thanks for your feedback - I'm very pleased that I was able to help.

    Bien à vous,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code to be applied in different worksheets
    By Fili Rojas in forum Non English Excel
    Replies: 0
    Last Post: 04-11-2013, 01:01 AM
  2. BeforeSave code makes excel crash every time
    By keb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2011, 03:04 PM
  3. [SOLVED] Object vs. New File in beforeSave event
    By Felix in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2006, 10:20 AM
  4. CREATING E-MAIL ATTACHMENT WITH 'BeforeSave Events' IN CODE
    By Chuckles123 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-08-2005, 01:02 PM
  5. Code Problem in BeforeSave Event
    By Kirk P. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2005, 08:31 PM

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