运行时错误 70:权限被拒绝
Runtime error 70: Permission Denied
我收到一条错误消息
"Runtime error 70: Permission Denied"
下面是我收到此错误的代码。
Sub reconwebscrap() ' ' reconwebscrap Macro ' ' Keyboard Shortcut: Ctrl+Shift+R
Dim requestsearchrange As Range
Dim cell1 As Range
Dim cell2 As Range
Dim entire As Range
Dim IE As Object
Dim revocdate As String
Dim i As Integer
Dim tags As Object
Dim tagx As Object
Dim tags2 As Object
Dim tagsx As Object
Application.DisplayStatusBar = True
i = 0
With ActiveWorkbook.Sheets(2)
Set requestsearchrange = .Range(.Range("B2"), .Range("B2").End(xlDown))
End With
ActiveWorkbook.Worksheets.Add
With ActiveWorkbook.Sheets(3)
Set entire = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
the_start:
Set IE = New InternetExplorerMedium
'Set IE = CreateObject("InternetExplorer.Application")
'-----------------------------------------------------------------------------------------------------------------
'These attributes decide the position of internet explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Top = 0
IE.Left = 0
IE.Width = 800
IE.Height = 600
'-----------------------------------------------------------------------------------------------------------------
'Disable the viewing of Internet Explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Visible = True
'-----------------------------------------------------------------------------------------------------------------
'Navigate to the website.
'-----------------------------------------------------------------------------------------------------------------
IE.Navigate ("https://ibid.abc.com/RMT/MyDashboard")
'-----------------------------------------------------------------------------------------------------------------
'Let the website load completely.
'Error handling in case the website is not available.
'-----------------------------------------------------------------------------------------------------------------
Do Until Not IE.Busy
DoEvents
Application.StatusBar = " Running"
Loop
'Do
'DoEvents
'If Err.Number <> 0 Then
'IE.Quit
'Set IE = Nothing
'GoTo the_start:
'End If
'Loop Until IE.readystate = 4
MsgBox "webpage has loaded"
revocdate = InputBox("enter the last revocation date")
Set tags = IE.document.getElementsByTagName("img")
'Set tags2 = IE.document.getElementById("dashboardSelect")
For Each cell1 In requestsearchrange
IE.document.getElementById("dashboardSelect").Value = "recipientSid"
IE.document.getElementById("quickSearchCriteriaVar").Value = cell1.Value
For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
Do Until Not IE.Busy
DoEvents
Loop
i = i + 1
Application.StatusBar = i & " Running"
Next cell1
Application.StatusBar = ""
End Sub
我在
中收到此错误
For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
在这段代码中,我试图在搜索框中输入一个数字,然后单击按钮。然后等待它加载,然后输入下一个数字。但它只对 excel sheet 中的第一个单元格执行此操作。之后我收到此错误。
我认为可能的原因如下:
在您的代码的某个位置,您获得了包含所有带有 img
标签名称的元素的集合。
稍后代码进入循环。在此循环的每次迭代中,单击此标记之一:
tagx.Click
我想这会触发一些 JS 脚本并且在 HTML 结构中进行了一些更改。这会导致之前获得的合集无法再使用,需要从头获得。
因此,如果您移动这部分代码:
Set tags = IE.document.getElementsByTagName("img")
进入这个循环,它应该可以工作。
这是您修改后的代码:
Sub reconwebscrap() ' ' reconwebscrap Macro ' ' Keyboard Shortcut: Ctrl+Shift+R
Dim requestsearchrange As Range
Dim cell1 As Range
Dim cell2 As Range
Dim entire As Range
Dim IE As Object
Dim revocdate As String
Dim i As Integer
Dim tags As Object
Dim tagx As Object
Dim tags2 As Object
Dim tagsx As Object
Application.DisplayStatusBar = True
i = 0
With ActiveWorkbook.Sheets(2)
Set requestsearchrange = .Range(.Range("B2"), .Range("B2").End(xlDown))
End With
ActiveWorkbook.Worksheets.Add
With ActiveWorkbook.Sheets(3)
Set entire = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
the_start:
Set IE = New InternetExplorerMedium
'Set IE = CreateObject("InternetExplorer.Application")
'-----------------------------------------------------------------------------------------------------------------
'These attributes decide the position of internet explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Top = 0
IE.Left = 0
IE.Width = 800
IE.Height = 600
'-----------------------------------------------------------------------------------------------------------------
'Disable the viewing of Internet Explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Visible = True
'-----------------------------------------------------------------------------------------------------------------
'Navigate to the website.
'-----------------------------------------------------------------------------------------------------------------
IE.Navigate ("https://ibid.abc.com/RMT/MyDashboard")
'-----------------------------------------------------------------------------------------------------------------
'Let the website load completely.
'Error handling in case the website is not available.
'-----------------------------------------------------------------------------------------------------------------
Do Until Not IE.Busy
DoEvents
Application.StatusBar = " Running"
Loop
'Do
'DoEvents
'If Err.Number <> 0 Then
'IE.Quit
'Set IE = Nothing
'GoTo the_start:
'End If
'Loop Until IE.readystate = 4
MsgBox "webpage has loaded"
revocdate = InputBox("enter the last revocation date")
'Set tags2 = IE.document.getElementById("dashboardSelect")
For Each cell1 In requestsearchrange
IE.document.getElementById("dashboardSelect").Value = "recipientSid"
IE.document.getElementById("quickSearchCriteriaVar").Value = cell1.Value
Set tags = IE.document.getElementsByTagName("img")
For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
Do Until Not IE.Busy
DoEvents
Loop
i = i + 1
Application.StatusBar = i & " Running"
Next cell1
Application.StatusBar = ""
End Sub
我收到一条错误消息
"Runtime error 70: Permission Denied"
下面是我收到此错误的代码。
Sub reconwebscrap() ' ' reconwebscrap Macro ' ' Keyboard Shortcut: Ctrl+Shift+R
Dim requestsearchrange As Range
Dim cell1 As Range
Dim cell2 As Range
Dim entire As Range
Dim IE As Object
Dim revocdate As String
Dim i As Integer
Dim tags As Object
Dim tagx As Object
Dim tags2 As Object
Dim tagsx As Object
Application.DisplayStatusBar = True
i = 0
With ActiveWorkbook.Sheets(2)
Set requestsearchrange = .Range(.Range("B2"), .Range("B2").End(xlDown))
End With
ActiveWorkbook.Worksheets.Add
With ActiveWorkbook.Sheets(3)
Set entire = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
the_start:
Set IE = New InternetExplorerMedium
'Set IE = CreateObject("InternetExplorer.Application")
'-----------------------------------------------------------------------------------------------------------------
'These attributes decide the position of internet explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Top = 0
IE.Left = 0
IE.Width = 800
IE.Height = 600
'-----------------------------------------------------------------------------------------------------------------
'Disable the viewing of Internet Explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Visible = True
'-----------------------------------------------------------------------------------------------------------------
'Navigate to the website.
'-----------------------------------------------------------------------------------------------------------------
IE.Navigate ("https://ibid.abc.com/RMT/MyDashboard")
'-----------------------------------------------------------------------------------------------------------------
'Let the website load completely.
'Error handling in case the website is not available.
'-----------------------------------------------------------------------------------------------------------------
Do Until Not IE.Busy
DoEvents
Application.StatusBar = " Running"
Loop
'Do
'DoEvents
'If Err.Number <> 0 Then
'IE.Quit
'Set IE = Nothing
'GoTo the_start:
'End If
'Loop Until IE.readystate = 4
MsgBox "webpage has loaded"
revocdate = InputBox("enter the last revocation date")
Set tags = IE.document.getElementsByTagName("img")
'Set tags2 = IE.document.getElementById("dashboardSelect")
For Each cell1 In requestsearchrange
IE.document.getElementById("dashboardSelect").Value = "recipientSid"
IE.document.getElementById("quickSearchCriteriaVar").Value = cell1.Value
For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
Do Until Not IE.Busy
DoEvents
Loop
i = i + 1
Application.StatusBar = i & " Running"
Next cell1
Application.StatusBar = ""
End Sub
我在
中收到此错误For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
在这段代码中,我试图在搜索框中输入一个数字,然后单击按钮。然后等待它加载,然后输入下一个数字。但它只对 excel sheet 中的第一个单元格执行此操作。之后我收到此错误。
我认为可能的原因如下:
在您的代码的某个位置,您获得了包含所有带有 img
标签名称的元素的集合。
稍后代码进入循环。在此循环的每次迭代中,单击此标记之一:
tagx.Click
我想这会触发一些 JS 脚本并且在 HTML 结构中进行了一些更改。这会导致之前获得的合集无法再使用,需要从头获得。
因此,如果您移动这部分代码:
Set tags = IE.document.getElementsByTagName("img")
进入这个循环,它应该可以工作。
这是您修改后的代码:
Sub reconwebscrap() ' ' reconwebscrap Macro ' ' Keyboard Shortcut: Ctrl+Shift+R
Dim requestsearchrange As Range
Dim cell1 As Range
Dim cell2 As Range
Dim entire As Range
Dim IE As Object
Dim revocdate As String
Dim i As Integer
Dim tags As Object
Dim tagx As Object
Dim tags2 As Object
Dim tagsx As Object
Application.DisplayStatusBar = True
i = 0
With ActiveWorkbook.Sheets(2)
Set requestsearchrange = .Range(.Range("B2"), .Range("B2").End(xlDown))
End With
ActiveWorkbook.Worksheets.Add
With ActiveWorkbook.Sheets(3)
Set entire = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
the_start:
Set IE = New InternetExplorerMedium
'Set IE = CreateObject("InternetExplorer.Application")
'-----------------------------------------------------------------------------------------------------------------
'These attributes decide the position of internet explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Top = 0
IE.Left = 0
IE.Width = 800
IE.Height = 600
'-----------------------------------------------------------------------------------------------------------------
'Disable the viewing of Internet Explorer window.
'-----------------------------------------------------------------------------------------------------------------
IE.Visible = True
'-----------------------------------------------------------------------------------------------------------------
'Navigate to the website.
'-----------------------------------------------------------------------------------------------------------------
IE.Navigate ("https://ibid.abc.com/RMT/MyDashboard")
'-----------------------------------------------------------------------------------------------------------------
'Let the website load completely.
'Error handling in case the website is not available.
'-----------------------------------------------------------------------------------------------------------------
Do Until Not IE.Busy
DoEvents
Application.StatusBar = " Running"
Loop
'Do
'DoEvents
'If Err.Number <> 0 Then
'IE.Quit
'Set IE = Nothing
'GoTo the_start:
'End If
'Loop Until IE.readystate = 4
MsgBox "webpage has loaded"
revocdate = InputBox("enter the last revocation date")
'Set tags2 = IE.document.getElementById("dashboardSelect")
For Each cell1 In requestsearchrange
IE.document.getElementById("dashboardSelect").Value = "recipientSid"
IE.document.getElementById("quickSearchCriteriaVar").Value = cell1.Value
Set tags = IE.document.getElementsByTagName("img")
For Each tagx In tags
If tagx.alt = "Search Request" Then
tagx.Click
End If
Next tagx
Do Until Not IE.Busy
DoEvents
Loop
i = i + 1
Application.StatusBar = i & " Running"
Next cell1
Application.StatusBar = ""
End Sub