-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
但保持歌廳對象不支持此屬性或方法
謝謝洙大部分時間都在嘗試一切 –
不客氣。很高興聽到它解決了。 – smozgur