小编use*_*346的帖子

使用vba将文本输入到html输入框中

我正在尝试使用VBA在Internet Explorer页面上输入一个值.我看过类似的帖子,但似乎无法确定我的问题.我对VBA有点流利,但HTML对我来说是新的.每次加载页面时,我访问的网页上的ID属性都会发生变化.以下是我尝试访问的HTML元素的镜头:

<input type="text" size="20" style="text-align: right; width: 261px;" autocomplete="off"    id="ext-comp-1067" name="user_numbers.1.number_1" class="x-form-text x-form-field x-form- num-field" title="">
Run Code Online (Sandbox Code Playgroud)

我目前使用的代码在这里:

    Sub OpenWebPage()

    Dim ObjCollection As Object
   Dim i As Long
Dim objElement As Object
Dim doc As Object
Dim form As Object



    Dim ie As Object
    Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
    ie.Navigate "http://11.182.123.21/#!/view/dashboards/dashboard-1"
    ie.Visible = True
    While ie.Busy
        DoEvents
   Wend


    Application.Wait Now + TimeValue("00:00:10")

 Set ObjCollection = ie.Document.getElementsByName("user_numbers.1.number_1").Value = "123"

End sub
Run Code Online (Sandbox Code Playgroud)

名称"user_number.1.number_1"我认为是html中唯一可用于查找此输入框的元素,每次打开网页时ID都会更改.如何在此字段中输入值?

谢谢!

html vba

7
推荐指数
1
解决办法
4万
查看次数

标签 统计

html ×1

vba ×1