+ Reply to Thread
Results 1 to 3 of 3

Disable one macro when saving a macro-enabled workbook while other macros continue.

  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Disable one macro when saving a macro-enabled workbook while other macros continue.

    I have a 2-worksheet Excel workbook (Excel 2007 and 2010) that serves as a template for users to enter collected data into. Each data set requires a unique file name (for tracking), so I wrote the macro below. Each time a user collects data, they open the template workbook and it directs them to immediately save the file into a specific directory. The code for that is as follows:

    Please Login or Register  to view this content.
    I know the FileFormat should be set to 52 for a macro-enable workbook, but I have it set to 51 for now because if the saved file is macro-enabled (as I need it to be), when it is opened later it will run the macro again asking for a file name. There are other macros I plan to insert into the template workbook for use in the saved macro-enabled workbook, so I need to disable the macro above once the new workbook is saved.

    I thought there may be code that could be inserted before the Message Box appears (perhaps an If Then statement) that would check the Active Workbook file name against the name of the template workbook. If they are the same, the macro will run because the filename match means the template was opened. If the Active Workbook does not match, then the macro is skipped. I tried a couple things but had no luck. Any suggestions or guidance would be greatly appreciated.
    Last edited by pike; 02-24-2011 at 03:40 AM. Reason: add code tags

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

    Re: Disable one macro when saving a macro-enabled workbook while other macros continu

    Deleted - GM
    Last edited by Greg M; 02-24-2011 at 11:18 AM. Reason: Deleted - requirements misunderstood

  3. #3
    Registered User
    Join Date
    02-23-2011
    Location
    Indianapolis, IN
    MS-Off Ver
    Excel 2007
    Posts
    2

    Smile Solved: Disable one macro when saving a macro-enabled workbook while other macros

    I finally had a breakthrough last night as I was helping my daughter with her science fair project (always good to step away to get a better perspective - a little sleep helps too). The code below does exactly what I want it to do.

    I do have another question I'll post in another thread. It concerns a macro that can "monitor" a range of data entry cells on a worksheet for user input.

    Thank you.

    Please Login or Register  to view this content.

+ 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