2016-05-13 112 views
-1

我一直使用VBA试图输入文本在IE浏览器,但我不断收到对象犯规支持此属性 的URL我想输入测试是 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").innerhtml更换IE.doucment.getelementsByName("t31092740").innertext ; IE.doucment.getelementsByID("t31092740").innertext但保持歌厅对象不支持此属性或方法

回答

0

1需要使用项目(通过使用或第一项......(“t31092749”)(0).value的)

2 - 极品使用Value属性

尝试:

IE.document.getElementsByName("t31092740").Item.Value = name 

注:这是当然的 “文件”。我认为它是你的代码中的错字。

+0

谢谢洙大部分时间都在尝试一切 –

+0

不客气。很高兴听到它解决了。 – smozgur