On Error Resume Next Can't skip the error

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

On Error Resume Next Can't skip the error

Post by YasserKhalil »

Hello everyone
I am using selenium in vba, and the file is sent to some users. I tried this code

Code: Select all

Sub CheckSeleniumInstallation()
    Dim bot As Object
    
    On Error Resume Next
    Set bot = CreateObject("Selenium.ChromeDriver")
    On Error GoTo 0
    
    If Not bot Is Nothing Then
        MsgBox "Selenium is installed!"

    Else
        MsgBox "Selenium is not installed or the specified object could not be created."
    End If
End Sub
But I still got an error
activex component can't create object

How to skip the error and display a message to the user to install Selenium first

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: On Error Resume Next Can't skip the error

Post by HansV »

When I run your code, I get:

S2490.png

Is your macro stored in a standard module or in a class module?
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Re: On Error Resume Next Can't skip the error

Post by YasserKhalil »

The code is in standard module
I expect that it will result as you did but the code insists on displaying the error.

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: On Error Resume Next Can't skip the error

Post by HansV »

Sorry, no idea. Anyone else?
Best wishes,
Hans

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: On Error Resume Next Can't skip the error

Post by rory »

Perhaps you have your VB Editor set to Break on all errors?
Regards,
Rory

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Re: On Error Resume Next Can't skip the error

Post by YasserKhalil »

Hello Mr. Rory
You are right. I have changed this option and forgot about it. Everything is OK now.

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: On Error Resume Next Can't skip the error

Post by HansV »

Good call, rory! :thumbup:

@Yasser: "Break in Class Module" is the best setting.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Re: On Error Resume Next Can't skip the error

Post by YasserKhalil »

Thanks a lot my tutor for the information.