Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-25
2
Medium Priority
?
406 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
What we learned in Webroot's webinar on multi-vector protection.
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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