Broker666
06-08-2013, 02:47 AM
Hi,
Basically what I am trying to achieve is to login to a website and access a node. So far I have been able to login to the website but am struggling with the code to access the relevant node and launch the PDF document it links to. Here's the code for far:
Sub Login_EDM()
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement
Dim SURL As String
Dim Uname As String
Dim PWord As String
Uname = Environ$("Username")
UserForm2.Show
PWord = UserForm2.TextBox1.Value
UserForm2.Hide
On Error GoTo Err_Clear
SURL = "https://wcweb.bak.com/ed/ed/LoginForms/login"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate SURL
oBrowser.Visible = True
Do
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
HTMLDoc.all.UserId.Value = Uname
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
HTMLDoc.LogonForm.submit
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
I have identified the Javascript for the node I am trying to access (attached in Word format). I am thinking i will need to use the 'execScript' method but my attempts so far have proved fruitless. I'm not really familiar with Javascript so any help would be really appreciated.
My attempts:
HTMLDoc.execScript "TreeView_SelectNode(folderViewControl1_trviewPvtfldr_Data, this,'folderViewControl1_trviewPvtfldrt15');"
Set CurrentWindow = IE.document.parentWindow
Call IE.document.parentWindow.execScript("TreeView_SelectNode(folderViewControl1_trviewPvtfldr_Data, this,'folderViewControl1_trviewPvtfldrt15');")
HTMLDoc.all(5).Click
Regards,
B666.
Basically what I am trying to achieve is to login to a website and access a node. So far I have been able to login to the website but am struggling with the code to access the relevant node and launch the PDF document it links to. Here's the code for far:
Sub Login_EDM()
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement
Dim SURL As String
Dim Uname As String
Dim PWord As String
Uname = Environ$("Username")
UserForm2.Show
PWord = UserForm2.TextBox1.Value
UserForm2.Hide
On Error GoTo Err_Clear
SURL = "https://wcweb.bak.com/ed/ed/LoginForms/login"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate SURL
oBrowser.Visible = True
Do
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
HTMLDoc.all.UserId.Value = Uname
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
HTMLDoc.LogonForm.submit
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
I have identified the Javascript for the node I am trying to access (attached in Word format). I am thinking i will need to use the 'execScript' method but my attempts so far have proved fruitless. I'm not really familiar with Javascript so any help would be really appreciated.
My attempts:
HTMLDoc.execScript "TreeView_SelectNode(folderViewControl1_trviewPvtfldr_Data, this,'folderViewControl1_trviewPvtfldrt15');"
Set CurrentWindow = IE.document.parentWindow
Call IE.document.parentWindow.execScript("TreeView_SelectNode(folderViewControl1_trviewPvtfldr_Data, this,'folderViewControl1_trviewPvtfldrt15');")
HTMLDoc.all(5).Click
Regards,
B666.