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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Data From Website 1

Status
Not open for further replies.

hilbertl3

Technical User
Joined
Sep 22, 2004
Messages
77
Location
US
Our firm regularly pulls data in the form of pdf files from a secure website. I have been tasked with finding a way to do this in visual basic. I'm sure it is possible, but I'm not sure how to tackle this. Here are the challenges:

1 the website is password protected so each user's password will need to be passed to the website in code.
2 the user needs to navigate through 5 levels to actually get to the page where they download the pdf files
3 the user needs to specify the name and location where they want to save the pdf files.

Has anyone done something like this before?

 
OK,

By gleaning data from tek-tips and non-tek-tips websites over the weekend, I have gotten about 25% of the way there.
I can now open a website, submit a username and password, login and activiate a hyperlink on a page to navigate.I've pasted this code below.
But if it were only that easy.....
Now the problem I'm encountering is that when I activate the hyperlink to navigate to a different page, a new web page window opens that again prompts me to enter the same username and password. When I access this site manually and click on the same link, a new web page DOES open, but I am directed to a different page at the website. Here is the code that I'm using to activate that link:

Private Sub Command3_Click()
Dim objElements As Object
Dim objElement As Object
Dim objToClick As Object
Set objToClick = Nothing
Set objElements = WebBrowser1.document.All.tags("a")

For Each objElement In objElements
Debug.Print objElement.innerText
If (objElement.innerText) = "Transactions" Then
''if LCase(objElement.outerHtml) Like "*somehtml*" then
Set objToClick = objElement
Exit For
End If
Next
objToClick.Click
End Sub

Any ideas what could be happening here?

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
As mentioned above,
this is the code I've put together to access the website and submit username and password:

Private Sub Command1_Click()
Me.WebBrowser1.navigate "websitenamehere"

End Sub

Private Sub Command2_Click()
Dim doc As HTMLDocument
Dim elem As HTMLInputElement
Dim frm As HTMLFormElement
Set doc = WebBrowser1.document
Set frm = doc.Forms(0)

'set username
Set elem = frm.Item("usr_name")
elem.Value = "usernamehere"
Set elem = frm.Item("usr_password")
elem.Value = "passwordhere*"
frm.submit

End Sub
 
Still looking for a solution to this...
Anyone?
 
I'm trying to do the same thing and can't get anything to work. I get the error message 'Class does not support Automation or does not support expected interface' when I try to run the very first line of me.webbrowser1.navigate.

I have the component Microsoft Internet Controls ticked.

I have another machine I use and that one gives me the compile error 'Method or data member not found' and I notice webbrowser1 is not a method listed with the 'me' object.
 
I was able to get this going so I may be able to help you. What exactly isn't working, though?
Can you paste your code?

hilbertl
 
I'm using your code from above. I've managed to get the command1 click event to work now. I'm on the command2 click event. I just get 'User-defined type not defined' for HTMLDocument, HTMLInputElement and HTMLFormElement. Where are these types defined?

Thanks
 
Go to Project -> References and make sure Microsoft Internet Controls and Microsoft HTML Object Library are both checked.

Next, Go to Project -> Components - >Controls
and make sure that Microsoft HTML Object Libary
and Microsoft Internet Controls are checked.

Hilbertl


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top