我一直在尝试使用VBA在IE中输入文本,但我不断得到对象不支持此属性 我试图输入测试的网址是 http://www.smartsurvey.co.uk/s/2XKL1/
我的代码是
Sub inputusername()
Dim IE As Object
Dim name As String
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
currenttime = Hour(Now())
If currenttime < 12 Then
g01 = "Morning"
ElseIf currenttime >= 18 Then
g01 = "Evening"
Else
g01 = "Afternoon"
End If
'Me.embtn.Visible = True
'MsgBox (g01 & " " & Application.UserName)
If MsgBox(g01 & " " & Application.UserName & " Please input your name on the website?", vbYesNo + vbQuestion) = vbNo Then
name = InputBox("Please type in your name")
Else
name = Application.UserName
End If
'MsgBox (Name)
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate ("http://www.smartsurvey.co.uk/s/2XKL1/")
Do While IE.Busy: DoEvents: Loop
IE.doucment.getelementsByName("t31092740").innertext = name
IE.document.getelementsByName("cmdGo").Item.Click
End With
' cleaning up memory
IE.Quit
Set IE = Nothing
MsgBox "Yippy Thanks"
End Sub
我试过替换IE.doucment.getelementsByName("t31092740").innertext
与IE.doucment.getelementsByName("t31092740").innerhtml
;
IE.doucment.getelementsByID("t31092740").innertext
但保持geting对象不支持此属性或方法
答案 0 :(得分:0)
1-需要使用物品(或第一项使用......(&#34; t31092749&#34;)(0).Value)
2-需要使用Value属性
尝试:
IE.document.getElementsByName("t31092740").Item.Value = name
注意:它是&#34;文件&#34;当然。我认为你的代码中是拼写错误。