2

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
2
  • What is CurrentWindow? Please post the entire code. Try to use objIE.Document.parentWindow.execScript Commented Feb 2, 2017 at 18:38
  • I've added my code so far. Please excuse the way it looks right now, I like to write something first and then clean up later. Commented Feb 2, 2017 at 18:49

2 Answers 2

1
Call CurrentWindow.execScript("viewObjectionLetter('letterId')")

This passes the literal value "letterId" to the function, which isn't going to get you anywhere. You need to find the actual value and pass that.

You can extract that from the page source, but since you don't show any HTML it's difficult to suggest how to do that.

Why not just click the link though?

Sign up to request clarification or add additional context in comments.

1 Comment

I'm working on getting the HTML to you. The reason why I don't just click the link is because I'm not sure how to handle it - this is how it looks in the source: <a onclick="viewObjectionLetter('127615001');return false;" href="#">Pending company response</a>
0

Thank you Tim.

The solution was as simple as you said, just click it.

Set objectionLetter = ie.Document.getElementsByTagName("a")
For Each objButton In objectionLetter
If InStr(LCase(objButton.innerHTML), "pending company response") Then objButton.Click
Next objButton

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.