我的问题是在代码的下一部分之前在网页上搜索一个名为“输入ID”类型的元素。下面的代码找不到这个元素,只是不停地循环。
Dim Elem As Object
Do
Set Elem = Nothing
Set Elem = document.all.getElementById("XXXXXX")
DoEvents
Loop While Elem Is Nothing
' Next part of code.谢谢..
发布于 2013-12-31 13:06:05
试试这段代码
Sub Login()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://appworld.blackberry.com/isvportal/home.do"
Do While IE.readystate <> 4
DoEvents
Loop
WaitFor 5
Dim signInButton As Object
Set signInButton = IE.document.getelementbyid("ssoLoginFrm_0")
signInButton.Click
End Sub
Sub WaitFor(NumOfSeconds As Long)
Dim SngSec As Long
SngSec = Timer + NumOfSeconds
Do While Timer < SngSec
DoEvents
Loop
End Sub发布于 2013-12-30 07:28:09
好吧,我还是把这个发出去。我认为在VBA中重构这一点并不难,如果您看到了逻辑:
public static Control FindAnyControl(this Page page, string controlId)
{
return FindControlRecursive(page.Form, controlId);
}
public static Control FindAnyControl(this UserControl control, string controlId)
{
return FindControlRecursive(control, controlId);
}
public static Control FindControlRecursive(Control parent, string controlId)
{
foreach (Control control in parent.Controls)
{
Control result = FindControlRecursive(control, controlId);
if (result != null)
return result;
}
return parent.FindControl(controlId);
}然后你就这样在你的页面里这样称呼它:
Control MyControl = new Control();
MyFoundControl = FindControl(this, "MyControlName");https://stackoverflow.com/questions/20771388
复制相似问题