MrPink1986
Active Member
- Joined
- May 1, 2012
- Messages
- 252
Hi,
I have created some code to connect to a website and enter the username and password required to login, once I am logged in I would like to click a button to load a certain page.
This I am having trouble with - I can connect no problem to the site and no issues here.
The code I am using is here;
The red text is my attempt to connect to the button and click.
The button on the site is named "download" and I have attached the code from the site below
}
function downloadTableData(value)
{
theform=document.forms[1];
myurl=******************.href;
var old = theform.action;
var oldmethod=theform.method;
theform.method="POST";
setElemValue(theform,"format",value);
setElemValue(theform,"downloadTable","mainTable");
setElemValue(theform,"querytitle","mainTable");
theform.action = "PresentationServlet";
theform.submit();
theform.action = old;
theform.method=oldmethod;
}
Help greatly appreciated on this.
I have created some code to connect to a website and enter the username and password required to login, once I am logged in I would like to click a button to load a certain page.
This I am having trouble with - I can connect no problem to the site and no issues here.
The code I am using is here;
Code:
Option Explicit
Sub OpenIE(password, username As String)
Dim Clica As Object
Dim Clica2 As Object
Dim IE As InternetExplorerMedium
Set IE = New InternetExplorerMedium
IE.Navigate ("https://products.markit.com/home/login.jsp")
IE.Visible = True
Do While IE.ReadyState <> 4 And IE.Busy
DoEvents
Loop
IE.Document.getElementById("username").Value = password
IE.Document.getElementById("password").Value = username
For Each Clica In IE.Document.getElementsByTagName("a")
If Clica.className = "button hsprite stylishButton fRight" Then
Clica.click
Set Clica = Nothing
Set IE = Nothing
Exit Sub
End If
Next Clica
Set Clica = Nothing
Set IE = Nothing
End Sub
Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub
[COLOR=#ff0000][U][I][B]Sub click_download()[/B][/I][/U][/COLOR]
[COLOR=#ff0000][U][I][B]'Set btnGo = IE.Document.form(0).all("downloadTable") ' method:submit is the button's name[/B][/I][/U][/COLOR]
[COLOR=#ff0000][U][I][B]'btnGo.click[/B][/I][/U][/COLOR]
[COLOR=#ff0000][U][I][B]IE.Document.getElementById("downloadTable").click[/B][/I][/U][/COLOR]
[COLOR=#ffd700]
[/COLOR]
[COLOR=#ffd700]End Sub[/COLOR]
Sub test()
OpenIE "xxx@xxxx.com", "xxxxxx"
Call click_download
End Sub
The red text is my attempt to connect to the button and click.
The button on the site is named "download" and I have attached the code from the site below
}
function downloadTableData(value)
{
theform=document.forms[1];
myurl=******************.href;
var old = theform.action;
var oldmethod=theform.method;
theform.method="POST";
setElemValue(theform,"format",value);
setElemValue(theform,"downloadTable","mainTable");
setElemValue(theform,"querytitle","mainTable");
theform.action = "PresentationServlet";
theform.submit();
theform.action = old;
theform.method=oldmethod;
}
Help greatly appreciated on this.