Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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