Web Browser Control How to do an Automatic Login (1 Viewer)

Local time
Today, 10:00
Joined
Dec 13, 2019
Messages
77
How would you use the web browser control to automatically login into a website using your username and password?
 

Isaac

Lifelong Learner
Local time
Today, 09:00
Joined
Mar 14, 2017
Messages
2,673
It looks like you can utilize the same type of code you would use when automating internet explorer to do webscrapes or set values to textboxes or click buttons. Whether you use things like GetElementByID vs. Forms(#) will depend a lot on the webpage. Looking at the webpage Source (and hoping that the elements are exposed in the source, which isn't always the case) and then playing around with GetDocumentByID or something similar are places to start?
 

Isaac

Lifelong Learner
Local time
Today, 09:00
Joined
Mar 14, 2017
Messages
2,673
There are a LOT of variables to account for (and sometimes ones that actually can't be accounted for and can't be done) when it comes to using VBA to manipulate webpages. I have heard great things about Selenium, if you're interested.

In the meantime, check out this sample. In this case I have a reference checked as pictured. The form will search Google for the text put into the textbox. In this case, success depended heavily on me being able to View Source (html) of the Google webpage and see a clearly labeled/named/ID'ed Element. Not every webpage will make that available I don't think, but this example might get you started. Note also that I used Forms(0) in my code--but that may not be proper for another website that has multiple areas to input/submit within the same page.

In this case one of the articles I referenced was this one, which seems to be one of the most comprehensive little collections of information about your subject - I especially appreciated the advice in this article on getting Intellisense where otherwise I wasn't getting any.

Testing 20200716_3.jpg


Testing 20200716_4.png


Testing 20200716_5.png
 

Attachments

  • Testing 20200716_3.accdb
    412 KB · Views: 20
Last edited:

Users who are viewing this thread

Top Bottom