Rithwik Sarma
Rithwik Sarma

Reputation: 51

How do I prevent pop-up boxes from coming up while executing the code?

POP UPI have a code which copied data between files. Some of these files have links to other files. So, when I run my macro to automatically copy data to other files, I get these pop-ups asking me whether I want to update these links. And after selecting "update", I get another pop-up saying that these links cannot be updated and asking me whether I would like to continue. Even while saving the file after copying, I get a pop-up saying "Be careful...." I do not want these pop-ups to appear while running the code. I want it to be fully automatic i.e. without any manual intervention

Upvotes: 1

Views: 855

Answers (1)

Tim Stack
Tim Stack

Reputation: 3248

Display messages can easily be avoided like so:

Sub test()
Application.DisplayAlerts = False

'Code

Application.DisplayAlerts = True
End Sub

EDIT
To avoid the Update warning:

Sub test()
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False

'Code

Application.AskToUpdateLinks = True
Application.DisplayAlerts = True
End Sub

And in case you're just opening a workbook, this is sufficient:

Application.Workbooks.Open Filename:="C:\test.xlsx", UpdateLinks:=False

Upvotes: 3

Related Questions