wyt3dr4g0n
Technical User
Ok so I've been developing a spreadsheet for use in collecting helpful information at the call center that I work at. It's been using webqueries and has worked great up to this point, however the primary intranet site I'm pulling data from has change it's login method to a more secure one and I'm no longer able to use the queries as before thanks to this. I CAN however use a browser object and get it to login using the following code:
That part is working perfectly, logs into the site and browses to the page with the table I need. My question is, what code do I need to select a table on this page, copy it, and paste into a sheet in excel? Is this possible? Would it be easier to save the document and just load the htm page in excel? I've done this manually and I can work with the data fine that way as well but I'm not sure of the code to save the page. Either method would be acceptible to me at this point.
Code:
Dim oHTML_Element As IHTMLElement
Dim OCUrl, loginURL, uid, pword, logmsg As String
Dim Table, Location As HTMLTable
loginURL = "[URL unfurl="true"]http://intranetloginsitetopassthrough"[/URL]
OCUrl = "[URL unfurl="true"]http://siteimneedingtopulltablefrom"[/URL]
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.Navigate loginURL
oBrowser.Visible = False 'set to true for testing
uid = InputBox("Please enter your username", "Username")
pword = InputBoxDK("Please enter your password", "Password")
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.Document
HTMLDoc.all.UserId.Value = uid
HTMLDoc.all.passWord.Value = pword
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
For Each oHTML_Element In HTMLDoc.getElementsByTagName("successOK")
oHTML_Element.Click: Exit For
Next
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
oBrowser.Navigate OCUrl
End Sub