Excel VBA:错误438“对象不支持此属性或方法
正在使用此代码使用Excel VBA在Web表单中input值:
Sub Call_Site(var1 As String) Dim oHTML_Element As Object 'IHTMLElement Dim sUrl As String sUrl = "https://www.example.com/page" Set oBrowser = CreateObject("InternetExplorer.Application") 'New InternetExplorer oBrowser.silent = True 'oBrowser.timeout = 60 oBrowser.navigate sUrl oBrowser.Visible = False With oBrowser Do While .Busy Or .ReadyState <> 4: Loop End With Set HTMLDoc = oBrowser.document.getElementsByClassName("nexcel")(0) With HTMLDoc HTMLDoc.getElementById("var1").Value = var1 End With Exit Sub
发生这样的情况:HTMLDoc.getElementById(“var1”)。Value = var1
正在返回错误:
Error 438 "object doesn't support this property or method
有时只发生
我不明白为什么这个错误有时会发生(通常是关键的时候)以及我能做些什么来防止它。
浏览器具有可见性,这一切似乎都很正常。
没有类似的答案,我find了一个解决scheme。