Excel web query to login into a website

0 votes

There are two different passwords on the page, thus I'm seeking for a macro or vba code to log me in. I've got some code that uses Internet Explorer to access websites, but it doesn't retrieve data because the web query browser is not logged in and I'm only logged into Internet Explorer, not the excel web query browser. As a result, I can't use my previously created web query connections to refresh or update data in Excel.

Sub WebLogin()
Dim a As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = True
    .Navigate "https://newtrade.sharekhan.com/rmmweb/login/LoginPage.jsp"
    Do Until .ReadyState = 4
        DoEvents
    Loop
    .Document.all.Item("loginid").Value = "myuserid"
    .Document.all.Item("brpwd").Value = "password1"
    .Document.all.Item("trpwd").Value = "password2"
    .Document.forms(0).submit
End With
IE.Quit
End Sub

Is there a way to update this code so that it uses the Excel Web Query Browser instead of Internet Explorer and can auto-log in with only a simple refresh of the external web connection that is already attached to my Excel sheet?

Sep 20 in Others by Kithuzzz
• 20,660 points
184 views

1 answer to this question.

0 votes
To be recognized by the web server in subsequent requests, you must obtain the cookie after signing in. Always login first in order to get that variable from the browser.

Grab the necessary cookies once you log in using the code you posted (try simulating your attempt in Internet Explorer using Network Recorder in the developer tools of the browser). After exiting IE, you can send those cookies to the server in the HTTP Post request.
answered Sep 21 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How to import data from a HTML table on a website to excel?

Hello  To import any HTML file in excel there ...READ MORE

answered Feb 10 in Others by gaurav
• 22,040 points
310 views
0 votes
0 answers

how to list the contents of a asset into an event

May 29, 2019 in Others by anonymous
254 views
0 votes
1 answer
0 votes
0 answers

Write a DAX query to obtain the bottom 5 customers based on the order price

Jan 22, 2020 in Others by anonymous
• 170 points
176 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
452 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,222 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
69 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
208 views
0 votes
1 answer

How to insert a picture into Excel at a specified cell position with VBA

Try this: With xlApp.ActiveSheet.Pictures.Insert(PicPath) With ...READ MORE

answered Oct 24 in Others by narikkadan
• 37,660 points
158 views
0 votes
1 answer

Trying to create an enclosing bookmark after pasting a picture from Excel into Word using VBA

Try this: Sub IMPORT_TO_WORD() Dim ws1 As Worksheet, ws2 ...READ MORE

answered Oct 30 in Others by narikkadan
• 37,660 points
38 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP