I am attempting to navigate to a specific page on a website. The first time I open the page, it asks for a username and password, and every other time after that, it remembers me and is already logged in. I know how to open a browser, how to navigate to specific page, and how to input the username and password to the correct places, all using VBA. I don't want to try and send a username and password when I am already logged in, because those tags wont even exist; the boxes to input those things aren't there. What I need to know is, is there a way to look for a specific tag to see if it is on the webpage in a VBA macro?
Edit: So, I've solved my problem by simply using "On Error Resume Next," so if it hits an error trying to input information to a element that doesn't exist, it'll just jump over it to the page navigation line. It may be a bit hacky, and I'll keep looking for a more elegant solution, but for now, it works. Thank you to all who replied!
set el = doc.getElementById("theId")assuming doc is a reference to the currently-loaded document. el will be Nothing if the tag is not there.IE.document.Forms(0).all("Login").Value = "generic_login" IE.document.Forms(0).all("Password").Value = "generic_password" IE.document.Forms(0).submitSo can i presume that "Login" and "Password" are the tag names? If not, any help you can give is greatly appreciated; I'm pretty new to anything HTML, and completely new to combining VBA and web pages.