Griffin
Griffin

Reputation: 14594

VBScript: wait for Excel MsgBox, Click OK

I've written a VBScript that automates a load of processing of Excel workbooks.

For some of these workbooks, a MsgBox is triggered when they are opened. This message box is interrupting the automation.

Is there a way to listen for this MsgBox in a VBScript and "click" OK when it pops up?

Upvotes: 2

Views: 3475

Answers (1)

Maks Gordeev
Maks Gordeev

Reputation: 351

Try to use this wrapper:

Application.DisplayAlerts = False
Application.Workbooks.Open ([your code])
Application.DisplayAlerts = True

This will suppress any warnings on opening, e.g. compatibility issues, etc.

UPDATE:

In case MsgBox is generated from workbook code, try to use this:

Application.AutomationSecurity = msoAutomationSecurityForceDisable

In case Late Binding is used, this will work:

Application.AutomationSecurity = 3

Read more: http://support.microsoft.com/kb/886633

Upvotes: 3

Related Questions