Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-22
4
Medium Priority
?
754 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 35

Assisted Solution

by:ste5an
ste5an earned 1000 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 1000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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