+ Reply to Thread
Results 1 to 8 of 8

Bypass Beforesave Macro while developing

Hybrid View

  1. #1
    Registered User
    Join Date
    07-14-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    5

    Bypass Beforesave Macro while developing

    I have a beginners knowledge of VBA macros in Excel 2007. I have developed a beforesave VBA macro for excel 2007 that checks that a number of cells have non-blank, non-zero values in them to force users to complete certain cells before saving. This seems to work quite well The workbooks are used to feed into a Word Mail Merge and it saves incomplete letters being sent out.

    My catch is with me saving the file. How do I save master copies of this workbook with the cells left blank or zero (the default) and hence override or bypass or ignore the beforesave macro? This is primarily while I am developing and testing the new excel workbook and so I can send out master copies to the other users.
    Last edited by MarkH000; 07-14-2011 at 03:57 AM.

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Bypass Beforesave Macro while developing

    you can disable events temporarily and then re enable them:
    Application.EnableEvents = False
    '
    '
    '
    Application.EnableEvents = True

  3. #3
    Registered User
    Join Date
    07-14-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Bypass Beforesave Macro while developing

    A further questions (pls excuse my ignorance):

    How do I overcome the final save issue where I want to save the s/sheet in its master form with blanks and zeroes and the beforesave macro ready to operate.

  4. #4
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Bypass Beforesave Macro while developing

    like i said in the previous post, when you want to make master copies,, disable the events and after you have finished saving the copies re enable them for example:
    Sub SaveCopies()
    Application.EnableEvents = False
    ActiveWorkbook.SaveAs "Copy1"
    ActiveWorkbook.SaveAs "Copy2"
    '
    '
    '
    Application.EnableEvents = True
    End Sub

  5. #5
    Registered User
    Join Date
    07-14-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Bypass Beforesave Macro while developing

    I'm just a bit slow. I think I understand now. Thank you so much for your guidance.

  6. #6
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Bypass Beforesave Macro while developing

    you are welcome :D
    Please if you are satisfied with the answer mark your thread as solved

    all the best

  7. #7
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Bypass Beforesave Macro while developing

    Mark:

    i am fairly new to VBA myself and I am working on a macro do do something very similar, could you post your code, I am hjaving a difficult time getting mine to work.

    Brad

  8. #8
    Registered User
    Join Date
    07-14-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Bypass Beforesave Macro while developing

    CBG05QB, No bother.

    As per the suggestion of mohd9876, I simply have a macro as below and do a run macro everytime I wish to save the file. The typical users of the Excel file won't be aware and hence will only successfully save the file when the cells are correctly entered. If you wish to save to a different file, you need to replace .Save with .SaveAs.

    -------
    Sub SaveCopies()
    Application.EnableEvents = False
    ActiveWorkbook.Save
    Application.EnableEvents = True
    End Sub
    ------

    Hope it helps.

+ 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