VBA在线输入数据并提交表格

Ste*_*son 7 excel vba excel-vba

我正在尝试使用VBA将数据从Excel提交到网络表单.问题发生在我试图选择和更新表单的*区域内.我尝试了各种选项(ID,名称等的getelement)没有任何成功.我认为这个问题与确定适当的要素有关.我已经看到有关在VBA中使用Locals功能的建议,但我不确定如何将其用于此目的.我有一种感觉,有一些经验的人可以通过查看网站上的源代码,使用VBA中的Locals或其他技术来快速解决这个问题.

表单已设置,因此所有字段都是文本,我可以在线输入/提交数据,没有任何问题.

在此先感谢您的任何帮助/建议.

Dim IE As Object

Sub submitFeedback3()
Application.ScreenUpdating = False

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://spreadsheetbootcamp.com/excel-efficiency-trainer-feedback/"

Application.StatusBar = "Submitting"
  ' Wait while IE loading...
 While IE.Busy
 DoEvents
 Wend
 **********************************************************************
 IE.Document.getElementById("Form_Attempts-1372643500")(0).Value = "1"
 IE.Document.getElementById("submit-1-1372643500")(0).Click
 **********************************************************************
 Application.StatusBar = "Form Submitted"
 IE.Quit
 Set IE = Nothing

Application.ScreenUpdating = True
End Sub
Run Code Online (Sandbox Code Playgroud)

San*_*osh 5

试试下面的代码

Dim IE As Object

Sub submitFeedback3()
    Application.ScreenUpdating = False

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://spreadsheetbootcamp.com/excel-efficiency-trainer-feedback/"

    Application.StatusBar = "Submitting"
    ' Wait while IE loading...
    While IE.Busy
        DoEvents
    Wend
    ' **********************************************************************
    delay 5
    IE.Document.getElementById("experience-1372700847").Value = "ddddd1"
    delay 5
    IE.Document.getElementById("Form_Time_Best-1372700847").Value = "ddddddddddd2"
    delay 5
    IE.Document.getElementById("submit-1-1372700847").Click
    '**********************************************************************
    Application.StatusBar = "Form Submitted"
    IE.Quit
    Set IE = Nothing

    Application.ScreenUpdating = True
End Sub

Private Sub delay(seconds As Long)
    Dim endTime As Date
    endTime = DateAdd("s", seconds, Now())
    Do While Now() < endTime
        DoEvents
    Loop
End Sub
Run Code Online (Sandbox Code Playgroud)