Excecl VBA: When a Dialog Appears that requires you to press "OK"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In VBA code, how can I handel a Microsoft Office Excel Dialog that pops up?
All I need to do is recogise that the dialog has appeard and press "OK".
 
Try:

Application.DisplayAlerts = False

'run all your code here

Application.DisplayAlerts = True


RBS
 
unfortunately that does not work. If you create a webquery on an Excel page
then disconnect your connection to the internet and then run the query, you
will of course get an error dialog. I am trying to find a way to handle that
error dialog in code. Any ideas???
--
Thanks
Bruce


RB Smissaert said:
Try:

Application.DisplayAlerts = False

'run all your code here

Application.DisplayAlerts = True


RBS
 
How about:

On Error Resume Next

'line of code causing the error

If Error.Number <> 0 Then
'code to handle this error
End If

Otherwise test for a valid connection first and if not present then
do Exit Sub or whatever suitable.


RBS

Bruce said:
unfortunately that does not work. If you create a webquery on an Excel
page
then disconnect your connection to the internet and then run the query,
you
will of course get an error dialog. I am trying to find a way to handle
that
error dialog in code. Any ideas???
 
Think you will need to test if the connection exists before you try to use it.

--
Regards,
Tom Ogilvy



Bruce said:
unfortunately that does not work. If you create a webquery on an Excel page
then disconnect your connection to the internet and then run the query, you
will of course get an error dialog. I am trying to find a way to handle that
error dialog in code. Any ideas???
 
Back
Top