2016-05-13 110 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