Web Query for password protected web-sites

waldymar

Board Regular
Joined
Feb 19, 2009
Messages
238
hello everyone,

I am trying to import data into Excel from a webpage using the web query function; however, the webpage requires a login and password. I have the required login and password, but I cannot figure out how to make excel automatically input these into the correct fields and login in order to import the data.

Since I am trying to make all of our databases update automatically, I don't want to enter this info everyday when the macro runs.

Any suggestions?
Thanks

Vadim
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You will need to look at the source HTML code for those pages to find the reference for those input boxes. From there it's plain sailing can you find out what these inputboxes are called or give us a link to the page so we can find out on your behalf
 
Upvote 0
The site is: www.wifa.ru
On the left side you can see the login and password fields. I would appreciate if you could teach me that I can do it by myself. I'm using Office 2003.
 
Upvote 0
Try this, I have highlighted the bits I think you need to double check.

Rich (BB code):
Sub WebLogin()
Dim a As String
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .Navigate "http://www.wifa.ru"
        Do Until .ReadyState = 4
            DoEvents
        Loop
        .document.all.Item("username").Value = "Username"
        .document.all.Item("user_password").Value = "Password"
        .document.forms(0).submit
    End With
End Sub
 
Last edited:
Upvote 0
Thanks a lot!
A couple of questions:
Does it matter that I use another web browser than Internet Explorer?
Is this a standard code for any web-site I would like to import into excel?
What does this mean - "Do Until .ReadyState = 4"?
 
Upvote 0
I'm not sure how to make this work with any other browser TBH. I use Firefox personally but I find if you want to get Microsoft applications to work together you're best sticking with other Microsoft apps. Please google using your prefered browser with VBA

ReadyState 4 bascially means 'idle' i.e. all html, javascript, css, advertising etc etc is loaded and IE is expecting your input. This may differ if you use your preferred browser

If you want to import data you best look at Excel's web connection wizard, this is IE based but it will happily download any tables etc you want. Some of the other board members might show you how you could run a SQL query (or something) if you are accessing a database you have permission to use
 
Last edited:
Upvote 0
Hey Dave,

Your code worked for the web page I wanted to use it on, and I was able to find the names for the login and pass. But this:

Code:
        .document.forms(0).submit

...seems to do something other than pressing the login button. I tried changing the 0 to a 1 but no dice - then it errors. Any tips on how I can press the login button, or search the html source to find its name and then use that name?

Thanks,
Tai
 
Upvote 0
Are there any other forms on your page?
 
Upvote 0
Sure thing, just PM them over I'll check them out for you
 
Upvote 0

Forum statistics

Threads
1,215,594
Messages
6,125,723
Members
449,255
Latest member
whatdoido

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top