Eliminate Save Prompt In Macro

  • When I record a macro to open another file (iifFile) and make a change in it and close it and return to the original file, I reply to the message to save the change, but when I replay the macro the save window still comes up. I want to eliminate this manual action. How? In a regular Excel file it works OK.
    Thanks,
    Leif

  • Re: Eliminating The Save Command In A Macro


    Not verified:


    I suspect

    Code
    Application.DisplayAlerts = False before the line with save/close


    and

    Code
    Application.DisplayAlerts = True


    on the line after..



    OR


    if you don't want to save it:

    Code
    ThisWorkbook.Saved = True


    before the line with close.


    p45cal

  • Re: Eliminating The Save Command In A Macro


    Thanks for your suggestion. I have tested it and find that I still get the same message: Do you want to save your changes?
    Any other ideas? Not sure why iif File format works different.
    Leif

  • Re: Eliminating The Save Command In A Macro


    Try

    Code
    activeworkbook.Close True


    or

    Code
    activeworkbook.Close False


    to close and save, and to close and not save, respectively.


    p45cal


    ps. it doesn't have to be 'activeworkbook', you can specify the workbook:

    Code
    Workbooks("myfilename.xls").close True
  • Re: Eliminating The Save Command In A Macro


    It still does not work. Remember we are dealing not with an .xls file but an .iif file format which behaves differently. The file that contains the Macro is an .xls file but that is not the one I am trying to save.
    Any other clues?
    Thanks,
    Leif

  • Re: Eliminate Save Prompt In Macro


    Please post your code (or if you want to go the whole hog, a cut down version of your excel file and a mini iif file), including the code which opens the file, indicating where it is when you get the message. I've been trying to duplicate your problem but without luck. If there are any variables or objects in the code, please tell us the type and value etc.


    p45cal

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!