VBA with Microsoft Access - check if an object exists

I am using VBA with Microsoft Access.

I set an object to an element inside WebBrowserControl, which sometimes exists, sometimes not.

Dim myWebBrowser As Object Dim myItemInsideWebpage As Object Set myWebBrowser = Me.WebBrowser0.Object Set myItemInsideWebpage = myWebBrowser.Document.GetElemendById("myDiv") 

If "myDiv" exists, it's awesome; if not, I want Access to let me know so I can handle it.

+8
vba ms-access activex webbrowser-control
source share
1 answer

I think it will be something like

 If myItemInsideWebpage Is Nothing Then ' doesn't exist Else ' does exist End If 

You may need to preface your “Install” statement with “Enable re-detection of the next” if an error occurs if “myDiv” does not exist.

+14
source share

All Articles