message box close

TiTuS

Board Regular
Joined
Nov 10, 2004
Messages
238
Is it possible to close a popup using the text that is in it as the paremeter... i get a meesage poping up sometimes when doing a refresh of my queries... is there anyway to make a code so if a msg box appears with certain writing in it, it automatically shuits?
and also a command so if it detects that message box opening then it also trigures the refresh all comand or something after clossing
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try something like this;

Code:
Sub Test()
    Dim MyMsg1 As String, MyMsg2 As String
    MyMsg1 = "Wait for 2 seconds...."
    MyMsg2 = "Normal MsgBox"
    '
    'some code here to select the msg text...
    'change the below line to strMsg = MyMsg2 to see the effect
    '
    strMsg = MyMsg1
    '
    '
    If strMsg = MyMsg1 Then
        Set WshShell = CreateObject("WScript.Shell")
        x = WshShell.Popup(strMsg, 2, "Test")
    Else
        MsgBox strMsg
    End If
End Sub
 
Upvote 0
ok so this is the text in the message box "The Web query returned no data. To modify the query, click OK, click the name of the external data range in the name box on the formula bar, and then click Edit Query on the External Data toolbar." (excluding the brackets) so i just type that in under "Sub Test()
Dim MyMsg1 As String, MyMsg2 As String
MyMsg1 = "Wait for 2 seconds...."
MyMsg2 = "Normal MsgBox"
??

or does it need something to go witth it.... note the message i want to stop is not one ive created its a "!" message from excel... will that change this from working on clossing it?
 
Upvote 0
Well, what I've understood from your first message was not the one, described in your last message.

So, better ignore my message ...
 
Upvote 0

Forum statistics

Threads
1,203,329
Messages
6,054,756
Members
444,748
Latest member
knowak87

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