Macro to answer Alert question

Amy Beryl

Board Regular
Joined
May 5, 2011
Messages
54
Hi all -

I have a macro that will open a bunch of files, update the links, and save them. Occasionally a link can't be updated and an alert pops up. Is there a way in the macro to answer that pop-up? I want to code "Continue" to the Alert.

Any help would be most appreciated.

Amy
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I have a macro

Can you paste your macro using the code tag [ CODE][ /CODE]
but without the spaces
so in short you want to ignore the error pop up? i believe the syntax you're looking for is
Code:
On Error Resume Next
but i can't tell you where to put it if i don't see the physical code.
 
Upvote 0
You can disable Excel alerts at the point they occur and reenable them after, for example:


Code:
    Application.DisplayAlerts = False
    ActiveWorkbook.Save
    Application.DisplayAlerts = True
 
Upvote 0
Code:
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum680.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum620.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close


Can you paste your macro using the code tag [ CODE][ /CODE]
but without the spaces
so in short you want to ignore the error pop up? i believe the syntax you're looking for is
Code:
On Error Resume Next
but i can't tell you where to put it if i don't see the physical code.
 
Upvote 0
using what john_w said your code should look like:


Code:
 Application.DisplayAlerts = False
 Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum680.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum620.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
Application.DisplayAlerts = True

or if you want to use error handling (*note i'm not sure if the alert counts as an error so this may not work):
Code:
On Error Resume Next
 Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum680.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
On Error Resume Next
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum620.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close

or i imagine you could do both, the world is your oyster
 
Upvote 0
You're right the On Error Resume Next didn't work. I guess the Alert box doesn't react to that. However, the Display Alerts = False did manage to skip the Alert box and continue with the macro. I know that that still means there may be broken links but baby steps.

Thanks so much for your help.

Amy

using what john_w said your code should look like:


Code:
 Application.DisplayAlerts = False
 Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum680.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum620.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
Application.DisplayAlerts = True

or if you want to use error handling (*note i'm not sure if the alert counts as an error so this may not work):
Code:
On Error Resume Next
 Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum680.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close
On Error Resume Next
    Workbooks.Open Filename:= _
        "K:\Finance\Financial Strategy\Financial Analysis\Budget\2020\Expense Summaries\Sum620.XLS", _
        UpdateLinks:=3
    ActiveWorkbook.Save
    ActiveWindow.Close

or i imagine you could do both, the world is your oyster
 
Upvote 0
Hello everyone,

I have a question related to this one. I use a macro to create a new file which I save through the same macro that created it. I disable the DisplayAlert during the whole time this macro works and it all works the way I want it to.

But after closing this new workbook, when I try to reopen it, I get two consecutive pop-up Excel windows, the first one asking me if the source workbook is safe enough to run a reparation procedure and the second displaying a listbox of what has been repared.
The first window has two button, 'Yes' or 'No', and I always click on 'Yes'. The second is just a list and the only button I can click on is 'Close' which is what I do manually. This is repetitive and it happens everytime I open a file created through the said macro for the first time.

I was wondering if there was some vba functions I could use to automatically answer these two windows. Unlike the first macro, it looks like using the DisplayAlerts property would be kind of inefficient since the default value for the first window is 'No' when I want to select 'Yes', am I wrong ?
Also I don't know if I can run a macro for this at all since I think it happens before the worksheets finish charging but I am new to vba so I might very well be mistaking.

Do you have any ideas ?

Thank you for reading,

Marie
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top