Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 无法从网页获取getElementById_Html_Vba - Fatal编程技术网

Html 无法从网页获取getElementById

Html 无法从网页获取getElementById,html,vba,Html,Vba,我正在尝试访问网页并更新用户名和密码,但无法获取getElementById 我试过谷歌和雅虎的类似代码,它们工作得非常好。下面是我正在使用的代码 Sub Openurl() Dim IE As Object Dim IEPage As Object Dim IEPageElement As Object Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True IE.navigate URL ' T

我正在尝试访问网页并更新用户名和密码,但无法获取getElementById

我试过谷歌和雅虎的类似代码,它们工作得非常好。下面是我正在使用的代码

Sub Openurl()

Dim IE As Object
Dim IEPage As Object
Dim IEPageElement As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True

IE.navigate URL

' The below piece of code also does not work

Do Until IE.readyState = 4 'READYSTATE_COMPLETE in early binding
DoEvents
Loop


Set IEPage = IE.Document

Set IEPageElement = IEPage.getElementById(cwsUID)
If Not IEPageElement Is Nothing Then


IEPageElement.Value = UserName

Set IEPageElement = Nothing

Else

MsgBox "Coould not find the '" & UNElementID & "' element ID on the page!", vbCritical, "Element ID Error"

Exit Sub

End If


End Sub

如果此代码有问题,请告诉我。 下面是源代码

input type="text" name="cwsUID" id="cwsUID" value="" placeholder="CWS ID" autocomplete="off" autofocus=autofocus

虽然我不是VB专家,但我相信您必须使用引号:
IEPage.getElementById(“cwsUID”)

因为
cwsUID
不是一个变量名,而是一个id。

我能够通过使用


Set IE=New InternetExplorerMedium

现在我正试图点击一个Javascript有人能帮我解决这个问题吗?