Share via

logging onto website using VBA

Anonymous
2014-03-01T02:50:52+00:00

Hello,

Wondering if it is possible to log into a website using code?

I have a button to hyperlink to a website,  can I include in the code to insert my username and password into the login fields? 

The reason I want to do this is, when in the field on my Ultrabook, I want to reduce time, clicks and the appearance of being clumsy when in front of a customer.

Any help would be appreciated.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

12 answers

Sort by: Most helpful
  1. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2014-06-09T03:05:46+00:00

    Dim GC As clsGC

    is what is expected. I bet you named your class clsWhatever which is why the compile error occurs.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-06-09T01:52:17+00:00

    Check this out: http://www.access-programmers.co.uk/forums/showthread.php?t=200838

    Thanks Tom,

    I had a look at the site and will give it a try in a couple of days. Fitting an alarm to car ATM.

    Will let you now how I go with the information.

    Scott

    Well Tom its been a while, sorry about that.

    I copied the code from the website in the hyper link. I changed IE to GC and InternetExplorer to GoogleChrome and created a class module for part of the code.

    I get an error: "User-defined type not defined." at Dim GC As clsGC

    As a beginner it looks like I need to add a Reference, but I don't know which one to use.

    Can anyone tell me what I need to do to get this working please?

    The code is as follows:

    Sub loginSite()

        On Error GoTo errhandler

        Dim GC As clsGC

        Dim input_user As HTMLInputElement

        Dim input_pass As HTMLInputElement

        Dim docDOM As HTMLDocument

        Set GC = New clsGC

        GC.Navigate ("http://www.********************************")

        Do Until GC.DocumentLoaded

            DoEvents

        Loop

        Set docDOM = GC.document

        Set input_user = docDOM.getElementsByName("username").Item(Index:=0)

        Set input_pass = docDOM.getElementsByName("password").Item(Index:=0)

        input_user.Value = "scott@************"

        input_pass.Value = "*************"

    CLASS MODULE

    option Compare Database

    Option Explicit

    Dim doc_loaded As Boolean

    Dim WithEvents GC As GoogleChrome

    Private Sub Class_Initialize()

        On Error Resume Next

        GC.Visible = True

        If Err.Number <> 0 Then

            Set GC = New GoogleChrome

            GC.Visible = True

            End If

        End Sub

    Public Sub Navigate(ByVal URL As String)

        doc_loaded = False

        GC.Navigate URL

        End Sub

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

        doc_loaded = True

    End Sub

    Public Property Get DocumentLoaded() As Boolean

        DocumentLoaded = doc_loaded

    End Property

    Public Property Get document() As HTMLDocument

        Setdocument = GC.document

    End Property

        Exit Sub

    errhandler:

        Debug.Print "error" & Err.Number

        Debug.Print Err.Description

    End Sub

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-03-08T22:28:44+00:00

    Check this out: http://www.access-programmers.co.uk/forums/showthread.php?t=200838

    Thanks Tom,

    I had a look at the site and will give it a try in a couple of days. Fitting an alarm to car ATM.

    Will let you now how I go with the information.

    Scott

    Was this answer helpful?

    0 comments No comments
  4. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2014-03-08T11:09:02+00:00

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2014-03-08T08:09:23+00:00

    This question has not been answered yet, anybody?

    Was this answer helpful?

    0 comments No comments