Solved

on access 2013 web browser control  to submit a username and password?

Posted on 2014-12-22
4
655 Views
Last Modified: 2014-12-23
how can i make with vba  that the web browser control will  put a user name and password on a web form and submit it ?
0
Comment
Question by:bill201
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 33

Assisted Solution

by:ste5an
ste5an earned 250 total points
ID: 40514535
It strongly depends on the web site itself and it's sometimes hard to do. It also depends on what you like to do with it.

Normally credentials for a login are queried by a form. Thus you need to interact with the site using the DOM.

Here is an example showing how to find an input element using early binding, so you need to reference the Microsoft HTML Library:

Option Compare Database
Option Explicit

Private NavigateComplete As Boolean
Private WithEvents m_WebBrowser As SHDocVw.WebBrowser

Private Sub FillAndSubmitForm()

  Dim Element As MSHTML.IHTMLElement
  Dim Elements As MSHTML.IHTMLElementCollection
  Dim InputElement As MSHTML.IHTMLInputElement
  
  Set Elements = m_WebBrowser.Document.getElementsByTagName("input")
  If Not Elements Is Nothing Then
    For Each Element In Elements
      If (TypeOf Element Is MSHTML.IHTMLInputElement) And (Element.Name = "q") Then
        Set InputElement = Element
        InputElement.Value = "Access VBA IE DOM"
        InputElement.Form.submit
      End If
    Next Element
  End If

  Set InputElement = Nothing
  Set Element = Nothing
  Set Elements = Nothing
  
End Sub

Private Sub btnLoadPage_Click()

  NavigateComplete = False
  m_WebBrowser.Navigate2 "google.com"

End Sub

Private Sub ctlWebBrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)

  If Not NavigateComplete Then
    NavigateComplete = True
    FillAndSubmitForm
  End If

End Sub

Private Sub Form_Load()

  Set m_WebBrowser = ctlWebBrowser.Object

End Sub

Private Sub m_WebBrowser_TitleChange(ByVal Text As String)

  Me.Caption = Text

End Sub

Open in new window


You need to examine your page with the IE dev tools (press F12). Then you can find the appropriate element names or ids.
0
 
LVL 39

Accepted Solution

by:
thenelson earned 250 total points
ID: 40514768
Frequently you can pass the user name / password to the website when you enter the website's URL like this:
    "https://username:password@www.websiteaddress.com/
This is an internet protocol so it works on many websites.

If that does not work with the website you are interfacing with, you will need to interact with the website as ste5an explains.

Here is a demo database that will show you how to use the webbrowser control and automation to interact with websites:
http://www.thenelson.name/#WebAccess
0
 

Author Closing Comment

by:bill201
ID: 40515884
thanks a lot
0
 
LVL 39

Expert Comment

by:thenelson
ID: 40515941
glad I could help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question