I am not very familiar with JavaScript - please forgive me if I my explanation does not make sense. I am trying to execute a JavaScript function that is using a variable that I can't find. Below is the JavaScript function in the page source.
function viewObjectionLetter(letterId)
{
objLetterWindow = window.open('viewObjectionLetter.do?filingId=12345678&letterId='+letterId+'&viewOnly='+isEditUpdateMode(),'objectionLetterWindow','scrollbars,resizable,height=500,width=960');
return false;
}
The source shows that when the link is clicked it executes the following function.
viewObjectionLetter('13579');return false;
In vba
Call CurrentWindow.execScript("viewObjectionLetter('letterId')")
returns a webpage error and the url shows no value for letterId. How can I find that value from the page in order to execute the function?
Thank you.
Edit: Here is the complete source code.
Sub loadSERFF()
Dim ie As New InternetExplorer
Dim user As String
Dim pass As String
Dim product_name As String
Dim project_number As String
Dim author_name As Variant
Dim btn As Variant
Dim objs As New Collection
Dim coTrack As New Collection
Dim respondBy As New Collection
Dim productName As New Collection
user = Range("A2").text
pass = Range("B2").text
'Set IE = InternetExplorer.Application
ie.Visible = True
ie.Navigate "https://login.serff.com/serff/signin.do"
Do
DoEvents
Loop Until ie.ReadyState = 4
'Must NOT already be logged into SERFF
Do
ie.Document.forms(0).all("userName").Value = user
ie.Document.forms(0).all("password").Value = pass
ie.Document.forms(0).submit
Loop Until ie.ReadyState = 4
Call pageLoad (ie)
ie.Navigate "https://login.serff.com/serff/viewOpenFilings.do"
Call pageLoad(ie)
'Need to account for multiple pages of open filings *IMPORTANT*
Set objectionsTags = ie.Document.getElementsByTagName("td")
i = 1
For Each objection In objectionsTags
If InStr(LCase(objection.innerHTML), "pending industry response") Then
coTrack.Add (objectionsTags(i - 4).innerHTML)
productName.Add (objectionsTags(i - 5).innerHTML)
i = i + 1
Else
i = i + 1
End If
Next objection
ie.Document.forms(0).all("trackingNumber").Value = coTrack(1)
Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = ie.Document.parentWindow
Call CurrentWindow.execScript("performQuickSearch('company');")
Call pageLoad(ie)
Call CurrentWindow.execScript("updateTab('objections');")
Call pageLoad(ie)
Call CurrentWindow.execScript("viewObjectionLetter('letterId')")
Call pageLoad(ie)
End Sub
CurrentWindow? Please post the entire code. Try to useobjIE.Document.parentWindow.execScript