Solved

How can I with MS Access VBA log into a website?

Posted on 2011-03-25
2
356 Views
Last Modified: 2012-06-27
I need to be able to log into Youtube with a command button in Ms Access. I have done this with other sites but Youtube i am having a problem. I either dont have the control name right or something else is wrong. I have attached the code, I took out the real user and password.  
Private Sub Command1_Click()
Dim User As String
Dim password As String
Dim site As String
Dim objIE As Object
Dim strSql As String
Dim ClientLoginAddress As String
username = "user"
password = "password"

YouTubeAddress = "https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252Findex&hl=en_US&ltmpl=sso"
site = YouTubeAddress
Set objIE = CreateObject("InternetExplorer.Application")
 
    With objIE
    .visible = True
    .Navigate site
        Do While .ReadyState <> 4
            DoEvents
        Loop
 
        With .Document.Forms(1)
            .username.Value = username
            .password.Value = password
            .submit.Click
            
            End With
    End With
End Sub

Open in new window

0
Comment
Question by:seanlhall
2 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35221056
You need to refer the controls by their ID's.

Here is the code which is tested and tried :)

Private Sub Command1_Click()
    Dim UserName As String, password As String, YouTubeAddress As String
    Dim objIE As Object
    
    UserName = "User"
    password = "Password"
    
    YouTubeAddress = "https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252Findex&hl=en_US&ltmpl=sso"
    Set objIE = CreateObject("InternetExplorer.Application")
    With objIE
        .Visible = True
        .Navigate YouTubeAddress
        Do While .ReadyState <> 4
            DoEvents
        Loop
        With .Document
            .getelementbyid("Email").Value = UserName
            .getelementbyid("Passwd").Value = password
            .getelementbyid("signIn").Click
        End With
    End With
End Sub

Open in new window


Sid
0
 

Author Closing Comment

by:seanlhall
ID: 35261096
Thank you.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now