PDA

View Full Version : Control Internet Explorer using active URL



buhay
12-29-2010, 11:39 AM
I am using this procedure below to enter trades into a webbased site by using internet control.

After navigating to the first URL = "https://xxx" which remains the same all the time, I have to click to the proceed button to load URL2 which is not fix and varies all the time.
I've been trying to replace the URL2 with the active URL that has been loaded after the first proceed button click by URL2 = "URL;" & myURL to load the active URL and it works sometimes but sometimes it just loads this adress "URL;" which is not I want.

Does anyone know how to replace URL2 so that it loads the active URL after the proceed button has been clicked?


Thanks in advance



Sub ControlInternetExplorer()

Dim URL As String
Dim URL2 As String
Dim IE As Object
Dim HTMLdoc As Object
Dim objexcel As Variant

URL = "https://xxx"
URL2 = "URL;" & myURL



Set IE = CreateObject("InternetExplorer.Application")


With IE

.Visible = True
.Navigate URL
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Set HTMLdoc = .Document

End With



With HTMLdoc.forms(0)

.elements("D999999224999").Value = Cells(i, "C").Value
.elements("D999999225999").Value = "RVP"
.elements("D999999247999").Checked = True
.elements("Proceed").Click

End With



With IE

.Visible = True
.Navigate URL2
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Set HTMLdoc = .Document

End With


With HTMLdoc.forms(0)

.elements("D999999071999").Value = Cells(i, "O").Value
.elements("D999999063000").Value = "UNIT"
.elements("D999999063001").Value = Cells(i, "K").Value
.elements("D999999132001").Value = Cells(i, "J").Value
.elements("D999999132002").Value = Cells(i, "L").Value
.elements("D999999077999").Value = Cells(i, "G").Value
.elements("D999999076999").Value = Cells(i, "H").Value
.elements("D999999226999").Value = Cells(i, "M").Value
.elements("Proceed").Click

End With


With IE

.Visible = True
.Navigate URL2
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Set HTMLdoc = .Document

End With




With HTMLdoc.forms(0)

.elements("Confirm").Click

End With



End Sub

buhay
12-29-2010, 01:56 PM
I mean how do I assign an url to the variable URL2 so that it loads the current page or if not possible the previous loaded page? There must be a way how to do it.