Solved

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

Posted on 2011-03-25
2
370 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
[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 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

762 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