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

问题描述:

我正在尝试使用VBA将数据从Excel提交到Webform在线。该问题发生在我正在尝试选择和更新表单的 * 区域内。我已经尝试了各种选项(通过ID,名称等),没有任何成功。我认为这个问题与确定适当的要素有关。我已经看到关于在VBA中使用本地化功能的建议,但是我不知道如何使用它来实现这一目的。我有一种感觉,有一些经验可以通过查看Webiste上的源代码,使用VBA中的本地语言或其他一些技巧来快速找出这一点。

I'm trying to use VBA to submit data from Excel to a webform online. The issue happens within the * area where I'm trying to select and update the form. I've tried a variety of options (getelement by ID, name, etc.) without any success. I believe the issue has to do with identifying the appropriate element. I've seen advice about using the Locals feature in VBA, but I'm not sure how to use that for this purpose. I have a feeling someone with some experience could figure this out very quickly by looking at the source code on the webiste, using Locals in VBA, or some other technique.

表单设置为所有字段都是文本,我可以在线输入/提交数据没有问题。

The form is set up so all fields are text and I can enter/submit data online with no problem.

提前感谢任何帮助/建议。

Thanks in advance for any help/suggestions.

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


/ p>

Try below code

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