gpt4 book ai didi

vba - 运行时错误 '91' : Object variable or With block variable not set while URL data Scripting in VBA

转载 作者:行者123 更新时间:2023-12-04 20:58:17 25 4
gpt4 key购买 nike

我正进入(状态

Run Time Error '91': Object variable or With block variable not set



而 URL 数据脚本

我在我应该执行我的代码(即popup.click)的代码末尾收到此错误。

我注意到的一件事是,如果我在 F8 的帮助下逐步运行下面的代码,我没有遇到这样的错误,但是如果我在 的帮助下执行代码,我就会遇到这个错误。运行按钮 .

还有一件事我只想提一下,当我使用 执行代码时运行按钮 弹出值在我检查时没有显示任何内容。
        Sub GoToWebsiteTest()
Dim appIE As InternetExplorerMedium
Dim tags As Object
Dim tagx As Object
Dim repo As Object
Dim popup As Object
Dim Element As HTMLButtonElement
Dim MyHTML_Element As IHTMLElement
Dim HTMLdoc As HTMLDocument

i = 0
Set appIE = New InternetExplorerMedium
sURL = "https://oneview.myurl.in/"
With appIE
.navigate sURL
.Visible = True
End With

Do While appIE.Busy Or appIE.readyState <> 4
DoEvents
Loop

appIE.document.getElementById("Username").Value = "xxx"
appIE.document.getElementById("Password").Value = "xxxx"

i = InputBox("type")

appIE.document.getElementById("txtcaptcha").Value = i

Set tags = appIE.document.getElementsByTagName("input")

For Each tagx In tags
If tagx.Type = "submit" Then
tagx.Click
End If
Next

Do While appIE.Busy Or appIE.readyState <> 4
DoEvents
Loop

Set popup = appIE.document.getElementById("ctl00_MainContent_gridUser_ctl00_ctl04_lnkG2")

' Here I am getting Object variable or With block variable not set error

popup.Click

最佳答案

试试这个,让我知道你是否有 MsgBox 或者它是否有效:

Sub GoToWebsiteTest()
Dim appIE As InternetExplorerMedium
Dim tags As Object
Dim tagx As Object
Dim repo As Object
Dim popup As Object
Dim Element As HTMLButtonElement
Dim MyHTML_Element As IHTMLElement
Dim HTMLdoc As HTMLDocument

i = 0
Set appIE = New InternetExplorerMedium
sURL = "https://oneview.myurl.in/"
With appIE
.navigate sURL
.Visible = True
End With

Do While appIE.Busy Or appIE.readyState <> 4
DoEvents
Loop

appIE.document.getElementById("Username").Value = "xxx"
appIE.document.getElementById("Password").Value = "xxxx"

i = InputBox("type")

appIE.document.getElementById("txtcaptcha").Value = i

Set tags = appIE.document.getElementsByTagName("input")

For Each tagx In tags
If tagx.Type = "submit" Then
tagx.Click
End If
Next

Do While appIE.Busy Or appIE.readyState <> 4
DoEvents
Loop



Set popup = appIE.document.getElementById("ctl00_MainContent_gridUser_ctl00_ctl04_lnkG2")

DoEvents
If Not popup Is Nothing Then
popup.Click
Else
MsgBox "popup is not defined!", vbOKOnly + vbCritical
End If

'''rest of your code
End Sub

关于vba - 运行时错误 '91' : Object variable or With block variable not set while URL data Scripting in VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42246931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com