1

I have a situation as running Excel Macro. I tried to get rid of the dialog box of this: https://drive.google.com/open?id=0BzzXkoIWuMAHOF9oV1o5dmFhcWc

As I was poking around, I got it fixed that the dialog wouldn't periodically pop up so that I wouldn't need to hit the cancel bottom every single time.

Previously, part of the code were this:

 Application.AskToUpdateLinks = False
 Application.DisplayAlerts = False
 Workbooks.Open Filename:=FullFileName

The successful code was this:

 Application.DisplayAlerts = False
 Workbooks.Open Filename:=FullFileName, UpdateLinks:=0

So what is the difference Application.DisplayAlerts = False and put the updatelinks:=0 at the end of the workbook object?

New Edited(8/10/2017):

I got an error somehow as I ran the macro again!!!

I have

Application.Calculation = xlCalculationManual
Application.AskToUpdateLinks = False
Application.ScreenUpdating = False
Workbooks.Open FileName:=FullFileName, UpdateLinks:=0

and Macro throw me an Error

Run-time error '9': Subscript out of range

I don't know why.

When I removed UpdateLinks:=0, it went through and yet it forced me to click cancel as the dialog popped up.

I knew where I got wrong. The variable of the destination file name was misplaced with no reason!

Community
  • 1
  • 1
Oliver Bird
  • 145
  • 2
  • 15

1 Answers1

5

If Application.AskToUpdateLinks is set to False, then Excel will automatically update the links (or try to update but fail and display an error message).

If the UpdateLinks parameter is 0 then the links will not be updated, not even tried, and no question will be asked. (BTW, if you want it to update the links you have to set this parameter to 3, not to 1).

Moreover, the first example changes the property of the Application object, while the second is a Method parameter, so if you open another Workbook after this, the first code will have an influence on it, whereas the second will not.

z32a7ul
  • 3,695
  • 3
  • 21
  • 45
  • So `AskToUpdateLinks` is a dialog box to ask me if you wanna update or not. Although I chose `FALSE`, which means I **turn off the dialog box**, Macro still update the links no matter what. To fix that, I need to shut down the workbook object to prevent automatically download. Thanks!!! It's really clear now. – Oliver Bird Aug 10 '17 at 13:29