運行時錯誤「91」對象變量或帶塊變量未設置:對象變量或帶塊變量未設置
而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
可能是沒有正常運行時,嘗試添加'DoEvents'之前'popup.Click' – R3uK
@ R3uK主席先生,我已經試過same.I添加兩線之間有足夠的時間代碼**雖然appIE.Busy或appIE.readyState <> 4:DoEvents:循環**代碼,但仍然錯誤沒有得到糾正。 – sagar
是的,我看到你在那裏使用它(那裏,它用於等待頁面加載),但我建議你**將它添加到'Set popup = ap ...'和'popup之間。點擊'。** – R3uK