• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to Log -in to a website to download the data

Balajisx

Member
Hi Team,

Can I get a VBA code to auto log-in to a secure webpage using the login credentials and download the data from the web application ?

Thanks in advance :)
 
Try
Code:
Sub Belleke()
    With CreateObject("InternetExplorer.Application")
    .Navigate "http://enter web page here"
    Do Until .ReadyState = 4
      DoEvents
    Loop
    DoEvents
  
    ie.Document.Forms(0).all("User").Value = "Balajisx"
    ie.Document.Forms(0).all("Password").Value = "password"
    ie.Document.Forms(0).submit
  End With
End Sub
 
Thank you Belleke. I tried your code however I got an error stating "Automaton error" The interface is unknown. I did a slight modification in the code.
Set ie = New InternetExplorerMedium
ie.Visible = True
ie.Navigate ("https://xxx.xyz/EDG/")
however when it comes to submit i am not able to log in. Please assist.
 
There's no one size fits all code for Web interaction/scraping.

You'll need to find the type of authorization required by the web site (such as OAuth2) and write code accordingly.

If using IE automation, you'll need to find out element/form control names that the site uses.
 
Hi Chihiro, please find the element below. I believe the name is submit.However When I write a code by using these name or class or type or value the page is not getting loaded. Please advise
upload_2017-5-18_19-4-48.png
 
for user name
input name="ctl00$MainContent$txtUserId" type="text" id="ctl00_MainContent_txtUserId" title="Enter User Name" autocomplete="off" style="width: 97%" /></p>

For Password

<input name="ctl00$MainContent$txtPwd" type="password" id="ctl00_MainContent_txtPwd" title="Enter Password" autocomplete="off" style="width: 97%" /></p>
 
Replace "User" & "Password" in code with "ctl00$MainContent$txtUserId" and "ctl00$MainContent$txtPwd" respectively.
 
I did chihiro. but still it does not allow me to go to the home page. However I given a break before submit in my coding and when I press login button in IE manually I am able to do it. I m stucked here :-(
 
Hi Balajisx! It's better to reveal the link or at least provide with one similar to what you are trying with at this moment to get a quicker and exact answer.
 
Hi Shahin, Since it is an confidential information, I am in a suitation not to reveal the link. Also I do have the similar one :-(
 
Back
Top