Application.DisplayAlerts Help

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I'm looking for a solution in the following VBA. I have 3 machines that open an HTML file in Dropbox at various times throughout the day. I have 2 separate paths because two of the machines Dropbox location is HOME and the other is FRONT. I haven't been able to get Dropbox on the FRONT machine changed to a HOME directory yet so it is what it is temporarily.

When the macro is run I get the error "Can Not Find "C:\Users\FRONT\Dropbox\DAILY_SALES_REPORTS\SHIFT.HTML" or vice versa depending on which machine runs the macro even though I have Application.DisplayAlerts set to FALSE.

Is there another way to disable that message box from displaying so we don't have to stop and click ok to proceed.

Thank you!!
B





VBA Code:
Sub Test()


    Dim IE As Object
    Application.DisplayAlerts = False
    
    On Error Resume Next
    Sheets("Sheet2").Select
    Range("A1:S1000") = "" ' erase previous data
    Range("A1").Select

       
    Set IE = CreateObject("InternetExplorer.Application")
        With IE
            .Visible = True
            .Navigate "C:\Users\FRONT\Dropbox\DAILY_SALES_REPORTS\SHIFT.HTML" ' should work for any URL
            .Navigate "C:\Users\HOME\Dropbox\DAILY_SALES_REPORTS\SHIFT.HTML" ' should work for any URL
            Do Until .ReadyState = 4: DoEvents: Loop
        End With


        IE.ExecWB 17, 0 '// SelectAll
        IE.ExecWB 12, 2 '// Copy selection
        ActiveSheet.PasteSpecial Format:="HTML", link:=False, DisplayAsIcon:=False
        Range("A1").Select
        IE.Quit
        Application.DisplayAlerts = True

End Sub
 

Attachments

  • Screenshot 2023-01-26 10.10.36.png
    Screenshot 2023-01-26 10.10.36.png
    5.4 KB · Views: 4

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You want things to just carry on or terminate when that happens? Then one way would be to use an error handler.

VBA Code:
Sub test()
'declarations here

On Error GoTo errHandler
'your code here

exitHere:
' reset and clean up
Exit Sub

errHandler:
If Err.Number = #### Then 'put correct error number here for your issue
   'do something for this issue
   Resume exitHere
Else
   'msgbox for other errors
End If

End Sub
 
Upvote 0
You want things to just carry on or terminate when that happens? Then one way would be to use an error handler.

VBA Code:
Sub test()
On Error GoTo errHandler
'your code here

exitHere:
' reset and clean up
Exit Sub

errHandler:
If Err.Number = #### Then 'put correct error number here for your issue
   'do something for this issue
   Resume exitHere
Else
   'msgbox for other errors
End If

End Sub
Hi Micron. The code needs to carry on. Where you refer to 'put correct error number here for your issue 'do something for this issue, it doesn't have an error number, it displays the image below requiring the user to click ok.
Screenshot 2023-01-26 10.10.36.png
 
Upvote 0
My apologies; I thought you were getting the message from Excel because I failed to look at your attachment. Display Alerts won't handle errors raised in IE.
In that case, I don't know what to tell you except to try another approach from Excel, such as validating which machine is running the code and use the correct path for that. The logic would be

If Instr(Application.Path,"FRONT")>0 Then 'code to use front. Same for HOME.
 
Upvote 0
My apologies; I thought you were getting the message from Excel because I failed to look at your attachment. Display Alerts won't handle errors raised in IE.
In that case, I don't know what to tell you except to try another approach from Excel, such as validating which machine is running the code and use the correct path for that. The logic would be

If Instr(Application.Path,"FRONT")>0 Then 'code to use front. Same for HOME.
Thank you!! I'll give that a go. Have a GREAT DAY!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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