首页 > 解决方案 > 自动化 IE - VBA 问题,无法为 HTML 中的对象赋值

问题描述

我正在构建一个代码,以在我的 Intranet 服务器中将 VBA 中的例程自动化到 IE。当我尝试为 HTML 中的对象赋值时,vba 返回错误,我不知道我需要做什么。

我的 Intranet 服务器的 Html 代码行。

选项“值”仅在我手动输入值时出现:

INPUT onkeypress=soNumero() class=WidthFull maxLength=9 value=20000 name=numseqrs

当我打开空白 html 时,不会出现此选项..

INPUT onkeypress=soNumero() class=WidthFull maxLength=9 name=numseqrs

我的子程序:(这需要任何打开的 IE 窗口和控件)

Sub test()

Dim Shell_Application As Object
Dim Open_Window As Object
Dim IE As Object
Dim ca As Integer
Dim ele As Object



Set Shell_Application = CreateObject("Shell.Application")

For Each Open_Window In Shell_Application.Windows
If TypeName(Open_Window.document) = "HTMLDocument" Then

Set IE = Open_Window
Exit For
End If
Next

If IE Is Nothing Then
    MsgBox "não achei"
    Else
    MsgBox "achei"

IE.document.getElementsbyClassName("numseqrs").value = "12345"

Set IE = Nothing
Set Shell_Application = Nothing


End Sub

当我尝试为 (12345) 赋值时"numseqrs",vba 返回错误Object does not support this property or method (Error 438)

标签: htmlvbaautomation

解决方案


推荐阅读