none
Problem using VBA to log into a website RRS feed

  • Question

  • Hi Guys,

    I have written this code that seems ok to me, unfortunately it does not run properly as I get a message like " Method "Document" of the object "IWebBrowser2" is not working". I post the code as follows

        

    Dim user, password As String
    user = Worksheets("Foglio2").Range("B8").Value
    password = Worksheets("Foglio2").Range("B9").Value


    Dim IE As Object, F As Long
    Dim myRColl, myDColl, KK As Long, i As Long, J As Long, myColl, myR, myTD
    '
    myURL = "WEBSITE NAME"     '<<<<
    Set IE = CreateObject("InternetExplorer.Application")
    '
    With IE
       .Navigate myURL
        .Visible = True
        .Document.all.Items("userName").Value = user
        .Document.all.Items("userPassword").Value = password
        .Document.all.forms(0).submit
        Do While .Busy: DoEvents: Loop              
        Do While .ReadyState <> 4: DoEvents: Loop   

        End With

    COULD YOU PLEASE HELP ME?

    THANKS IN ADVANCE

    Monday, April 4, 2016 7:03 PM

All replies

  • I can't help with your code since you need to have an actual website to test.  I've had a lot of problems with IE 11.  I would recommend using Selenium Basic rather than Microsoft Internet Controls.  It comes with a lot of Excel examples.  It supports selecting elements with Xpath which is extremely powerful.  It supports Firefox, Chrome, IE and Edge.  I just finished a project with it and was really impressed.  It seems to be well supported with new updates every few months.  The latest release is 2.0.9.0.

    Selenium is used to test websites and is used by almost everyone.  You can use it with C#, Java, Ruby and other languages.  Someone developed Selenium Basic which supports VB.NET and VBA.

    Example

    Sub GmailSignIn()
    
      Dim drv As ChromeDriver
    
      Set drv = New ChromeDriver
      drv.Get "https://accounts.google.com/ServiceLogin"
      drv.FindElementById("Email").SendKeys "your email"
      drv.FindElementById("next").Click
      drv.FindElementById("Passwd").SendKeys "your password"
      drv.FindElementById("signIn").Click
      drv.Quit
    End Sub



    • Edited by mogulman52 Tuesday, April 5, 2016 12:25 AM
    Monday, April 4, 2016 11:15 PM
  • Just passing by to thank mogulman52 as now I'll be able to automate WhatsApp from Excel with VBA.

    Edit: I just saw the download link.


    http://www.ambienteoffice.com.br - http://www.clarian.com.br



    Tuesday, April 5, 2016 12:48 PM