Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open a password protected webpage in vba 2

Status
Not open for further replies.

9August84

Programmer
Apr 15, 2009
8
0
0
IN
Can somebody tell how to open a password protected webpage in VBA,
Currently I use the below code to open a webpage

Code:
Sub openweb()
strURI = "[URL unfurl="true"]www.google.com"[/URL]
Set ie = CreateObject("internetexplorer.application")
ie.Navigate strURI
end sub
 
9August84,
Take a look at faq707-6400, it shows how to log into a website and move date into Excel using Tek-Tips as the target.

[tt]GetMyTekTipsReplies[/tt] is an example of what your looking for.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thank you very much for your valuable post. It was very helpful for me.
 
The FAQ you suggested was very helpful. I have one more question. Can i skip any unwanted pop up comes when i try to open up a desired page? Any clues?

Thanks in advance.
 
CautionMP,

Did you write that FAQ? I found it quite interesting. I've never had a need to do such, and therefore haven't tried before.

I tested the code, and it wouldn't complete without my going in and editing the query to tell it which table(s) to import from within Excel (2007).

Also, is there a way to edit the same code, to have it go into each reply in the list, and actually pull whole threads in? I suppose it'd just be making the IE object go follow each link, and then import each table. Then in my case, there'd have to be an extra piece somewhere to specify each table to import, as I did with this example.

Either way, it's a neat idea.

--

"If to err is human, then I must be some kind of human!" -Me
 
9August84,
No but, if it's a "static" object that is hidden in the initial page then displayed with some type of scripting language it should be possible to isolate the "pop up" and close it (tek-tips used to do something similar).

kjv1611,
Yes. It was written and tested in Excel 2k in WinXP using IE5 (or 6) so it doesn't surprise me that it doesn't work in Excel 11, (IMHO) web query features got better and better with each release.

And yes, I believe this will work without loosing the [tt]objAnchors[/tt] collection.
Code:
...
Dim objAnchors As Object
Dim objAnchor As Object
...
Set objAnchors = objIE.Document.Links
If objAnchors.Length <> 0 Then
  For Each objAnchor In objAnchors
     If objAnchor.href Like "*viewthread*" Then
      objAnchor.Click
      While objIE.Busy: Wend
      While objIE.Document.ReadyState <> "complete": Wend
      'Do your thing to capture the post here
      '...
      'Then go back to the listing
      objIE.GoBack
    End If
  Next objAnchor
End If
...

CMP
 
Thanks! I'll have to play around with adding that in sometime soon, assuming I don't forget. [wink]

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top