+ Reply to Thread
Results 1 to 21 of 21

Prevent message boxes from another macro from popping up

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Prevent message boxes from another macro from popping up

    Hey everyone, so I currently have a macro that leads two other codes to run. I put these codes into my current macro using Application.Run. The problem I am running into is that the two macros that I am running contain message boxes within them to let the user know the macro is done. The macro I am working on now is supposed to make the process quicker but when the messages boxes come up and the user has to click ok or hit enter, it adds a lot of time to the process. This script could sometimes be used to run each of the other programs hundreds of times. I have tried putting Application.DisplayAlerts=False into the code so that it prevents these other boxes from appearing, but they still come up. Can anyone help with this? I would get rid of the messages inside the two scripts I am running, but I need those for when they are run on their own. I'll try to explain better below by showing you what I'm working with.

    Please Login or Register  to view this content.
    Basically I am running two programs based on a list of values that are set in row 4. The values start in cell I4 and carry on to the right. The two macros I am running inside of this one both depend on the value of cell I4. So the code takes the value of I4, runs "CreateSL" and "NewFileSL" and then deletes that cell so that the next item in the list moves into I4. The code does this until I4 is empty. My problem is that both "CreateSL" and "NewFileSL" contain message boxes at the end of their code. I would prefer not to comment out these message boxes each time I want to run this script because they need to be there for times when these scripts are run by themselves.

    Any help is greatly appreciated, thanks.
    Last edited by sczerniak; 07-11-2013 at 11:16 AM. Reason: fixing typo

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    Application.DisplayAlerts only works with dialogs that are generated by the system, not by individual macros or other applications. You will need to edit the other macros to stop the messages.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Would it be possible to include If statements into my two other codes so that the messagebox doesn't appear while my code is running?
    something along the lines of:

    Please Login or Register  to view this content.
    Forgive my crude coding here
    Last edited by Leith Ross; 07-11-2013 at 11:28 AM. Reason: Added Code Tags

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    Can you post the code for the other 2 macros?

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Prevent message boxes from another macro from popping up

    I think you want this...


    Please Login or Register  to view this content.



  6. #6
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Here are both of the other macros.

  7. #7
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    @snb
    Could you explain this code a little bit. Like where should I put it and what it is doing.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    I have commented out the messages from the code. You can copy and paste this code over the qoriginal.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Quote Originally Posted by sczerniak View Post
    I would prefer not to comment out these message boxes each time I want to run this script because they need to be there for times when these scripts are run by themselves.
    I really don't want to comment and uncomment everytime I run this macro.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    Post your workbook and I will see what I can to do to make that happen.

  11. #11
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Ok here it is. I removed a lot of other stuff that doesn't pertain to this question. Also, the actual sheet is over 1000 rows tall in the "Master List" sheet.

    Upload Macro.xlsm

    Thank you very much for trying.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    I changed CreateSL and NewFileSL to take a boolean argument. The default is false which allows the message to be displayed. In the macro SaveAllSL, the value is passed in as True to prevent the message from displaying. The atached workbook has the updates.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Where are the new Macros, I don't see them.

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    There are in the same place as the old macros. The only thing I changed was adding a argument named bHideMsg and adding a If statement to the message.

  15. #15
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    It seems like the macros are not showing up after adding the ByVal bHideMsg As Boolean inside the parentheses of the name.

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczernia,

    That's true. Excel hides any Sub procedure macro that has arguments.

  17. #17
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    So how do I go about executing them and editing them in the future?

  18. #18
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    Just like you always have done by including the macro name in your code and using the VB Editor (ALT+F11) to make changes.

  19. #19
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    Normally I would go View>Macros>View Macros>Select the one I wanted>Edit.
    Once there, the VB Editor would appear and I could modify the code and also run it. Now that I have added these suggestions, the code does not appear within the list so I am confused on how to access it. Sorry if it's a dumb question.

  20. #20
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Prevent message boxes from another macro from popping up

    Hello sczerniak,

    You will need to create 2 new macros to call theses macros. Your 2 new macro will show up in the Macro dialog. Rename these to what you want.

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Prevent message boxes from another macro from popping up

    That solution also didn't work. I guess this just isn't meant to work. Thanks for trying.

+ 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