href javascript - trying to "click" in vba

ddotson

Board Regular
Joined
Nov 9, 2004
Messages
57
Good morning,

I am working through a list on an excel spreadsheet that holds the variables needed to access records on website. I am able to get to a page where a javascript popup causes me some issues.. I am trying to get some help with my code to "click" on the link and have the pop up displayed. My code does not give any errors, but when I step through the code, the page simply refreshes when the operable line is ran... my code is as follows:




Sub BackshopMacro()


Dim IE As Object

Dim ControlID As String
Dim ImpliedCapRate As String
Dim NoteID As String
Dim PropertyID As String

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


IE.Navigate "http://backshop.fairviewres.com/Locator/LoanLocator.aspx" 'load the Backshop Loan Locator page

Do
DoEvents
Loop Until IE.ReadyState = 4


IE.document.All("Login1$Login1$UserName").Value = "XXXX"

IE.document.All("Login1$Login1$Password").Value = "YYYY"

IE.document.All("Login1$Login1$LoginButton").Click


Do
DoEvents
Loop Until IE.ReadyState = 4


'Application.Wait (Now + TimeValue("0:00:03"))


'This is where we start the Loop

Sheets("Sheet1").Select

Range("A2").Select

Do Until ActiveCell.Value = ""

ControlID = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
ImpliedCapRate = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
NoteID = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
PropertyID = ActiveCell.Value



IE.Navigate "http://backshop.fairviewres.com/Locator/LoanLocator.aspx"

IE.document.All("ctl00$cph$LoanLocatorSearch1$ControlID").Value = ControlID

Dim Doc As HTMLDocument
Set Doc = IE.document




Do
DoEvents
Loop Until IE.ReadyState = ReadyState_Complete

'Application.Wait (Now + TimeValue("0:00:03"))

IE.document.All("ctl00$cph$LoanLocatorSearch1$btnSearch").Click



Do
DoEvents
Loop Until IE.ReadyState = 4

While IE.Busy
DoEvents
Wend

'Application.Wait (Now + TimeValue("0:00:03"))

IE.document.getElementbyID("ctl00_cph_LoanLocatorSearch1_SearchResults1_GridViewResults_ctl02_lnkDealName").Click

Application.Wait (Now + TimeValue("0:00:03"))


IE.Navigate "http://backshop.fairviewres.com/Property/Property.aspx?controlid=" & ControlID & "&noteid=" & NoteID & "&propertyid=" & PropertyID


IE.Navigate "http://backshop.fairviewres.com/Underwriting/UnderwrittenCFHeader.aspx?controlid=" & ControlID & "&propertyid=" & PropertyID & "&noteid=" & NoteID & "&action=propchange&underwrittencfheaderid=0&ucfuaname="


'IE.document.All("ctl00$cph$CapRate$NB").Value = ImpliedCapRate

'IE.document.All("ctl00$cph$UpdateAddNewDelete2$UpdateButton").Click

IE.document.parentWindow.execScript "__doPostBack('ctl00$cph$btnShowPopup','');"
Application.Wait (Now + TimeValue("0:00:03"))

Call IE.document.parentWindow.execScript("__doPostBack('ctl00$cph$btnShowPopup','')", "JavaScript")

'IE.document.getElementbyID("__doPostBack('ctl00$cph$btnShowPopup',''").Click



Sheets("Sheet1").Select
ActiveCell.Offset(1, -3).Select

Loop

End Sub


The html looks like this:

a id="ctl00_cph_btnShowPopup" href="javascript:__doPostBack('ctl00$cph$btnShowPopup','')">> Assign/Change Operating Statements</a


Any assistance that can be provided would be greatly appreciated!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top