Vba 环 错误转到0 'IE.ExecWB-OLECMDID\u SELECTALL,OLECMDEXECOPT\u dont计算器 'IE.ExecWB-oclemdid\u COPY,oclemdexecopt\u DODEFAULT '从正文中获取一些文本 strCountBody=IE.document.body.innerText lStartPos=仪表(1,strCountBody,“视图”) lEndPos=lStartPos+1 TextIWant=Mid$(strCountBody、lStartPos、lEndPos-lStartPos) ActiveCell=TextIWant 以 即退出 设置IE=无 端接头
我做了以下工作:Vba 环 错误转到0 'IE.ExecWB-OLECMDID\u SELECTALL,OLECMDEXECOPT\u dont计算器 'IE.ExecWB-oclemdid\u COPY,oclemdexecopt\u DODEFAULT '从正文中获取一些文本 strCountBody=IE.document.body.innerText lStartPos=仪表(1,strCountBody,“视图”) lEndPos=lStartPos+1 TextIWant=Mid$(strCountBody、lStartPos、lEndPos-lStartPos) ActiveCell=TextIWant 以 即退出 设置IE=无 端接头,vba,excel,internet-explorer,outlook,Vba,Excel,Internet Explorer,Outlook,我做了以下工作: 删除了末尾的循环 将strCountBody更改为字符串类型 设置ActiveCell=TextIWant而不是粘贴 处理HTML框架 子测试jh() 作为对象“HtmlButtoneElement”的Dim元素 将btnInput设置为对象的MSHTML.HTMLInputElement Dim ElementCol作为对象的MSHTML.IHTMLElementCollection 将链接设置为对象的MSHTML.htmlanchoreElement 将strCountB
- 删除了末尾的
循环
- 将strCountBody更改为字符串类型
- 设置
而不是粘贴ActiveCell=TextIWant
- 处理HTML框架
子测试jh()
作为对象“HtmlButtoneElement”的Dim元素
将btnInput设置为对象的MSHTML.HTMLInputElement
Dim ElementCol作为对象的MSHTML.IHTMLElementCollection
将链接设置为对象的MSHTML.htmlanchoreElement
将strCountBody设置为字符串
暗淡的lStartPos与长
长得一样暗
Dim TextIWant作为字符串
像绳子一样模糊
模糊的物体
设置IE=CreateObject(“InternetExplorer.Application”)
范围(“B7”)。激活“这是在B7上找到的链接:http://sar.paragonrels.com/publink/default.aspx?GUID=bc3565b3-4b55-46e1-94bf-b8b68ee32ada&报告=是
Lurl=ActiveCell.Value
ActiveCell.Offset(0,1).激活“我想将结果粘贴到C7中”
可见=真实
与IE
我是卢尔
出错时继续下一步
请稍等。ReadyState 4或。忙
应用程序。等待(1)
如果错误号=-2147417848,则在客户端断开连接的情况下退出Do
环
IE.navigate IE.document.frames.Item(3).位置
请稍等。ReadyState 4或。忙
应用程序。等待(1)
如果错误号=-2147417848,则在客户端断开连接的情况下退出Do
环
错误转到0
'IE.ExecWB-OLECMDID\u SELECTALL,OLECMDEXECOPT\u dont计算器
'IE.ExecWB-oclemdid\u COPY,oclemdexecopt\u DODEFAULT
'从正文中获取一些文本
strCountBody=IE.document.body.innerText
lStartPos=仪表(1,strCountBody,“视图”)
lEndPos=lStartPos+1
TextIWant=Mid$(strCountBody、lStartPos、lEndPos-lStartPos)
ActiveCell=TextIWant
以
即退出
设置IE=无
端接头
我做了以下工作:
- 删除了末尾的
循环
- 将strCountBody更改为字符串类型
- 设置
而不是粘贴ActiveCell=TextIWant
- 处理HTML框架
strCountBody
应该是StringThank类型。当我改为字符串时,我得到了“运行时错误'5':无效的过程调用或参数”。当我使用Set时,我得到了“运行时错误'424':需要对象”。(我确实确保Dim语句与代码的更改相匹配。)想法?注释掉错误恢复下一步的,看看发生了什么因为strCountBody
是一个对象,您需要使用Set。strCountBody
应该是string类型谢谢。当我改为字符串时,我得到了“运行时错误'5':无效的过程调用或参数”。当我使用Set时,我得到了“运行时错误'424':需要对象”。(我确实确保Dim语句与代码的更改相匹配)想法?在下一步的错误恢复中注释掉,看看发生了什么谢谢,迭戈!帧处理是我无法胜任的。谢谢,迭戈!帧处理是我的能力范围之外的。
Sub FollowLinkAddress()
Dim oDoc As Object
Dim h As Object
Dim xlApp As Object
Dim xlWB As Object
Dim xlSheet As Object
Dim olItem As Outlook.MailItem
Dim vText As Variant
Dim sText As String
Dim vItem As Variant
Dim i As Long
Dim rCount As Long
Dim bXStarted As Boolean
Set itm = ActiveInspector.CurrentItem
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox "No Items selected!", vbCritical, "Error"
Exit Sub
End If
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Application.StatusBar = "Please wait while Excel source is opened ... "
Set xlApp = CreateObject("Excel.Application")
bXStarted = True
End If
On Error GoTo 0
'Open Excel
Set xlWB = xlApp.Workbooks.Open("filepath")
Set xlSheet = xlWB.Sheets("Sheet1")
rCount = xlSheet.UsedRange.Rows.Count
'MsgBox rCount 'Used during testing
If itm.GetInspector.EditorType = olEditorWord Then
Set oDoc = itm.GetInspector.WordEditor
For Each h In oDoc.Hyperlinks
'h.Follow
'Process each selected record
For Each olItem In Application.ActiveExplorer.Selection
sText = olItem.Body
vText = Split(sText, Chr(13))
'MsgBox sText 'Again for testing
'Check each line of text in the message body
For i = UBound(vText) To 0 Step -1
If InStr(1, vText(i), "sar.paragonrels.com/publink/default.aspx?GUID") > 0 Then
rCount = rCount + 1
vItem = Split(vText(i), Chr(34)) 'Chr34 is double quotes
xlSheet.Range("B" & rCount) = Trim(vItem(1))
End If
Next i
' xlWB.Save
Next olItem
Next
End If
If bXStarted Then
xlApp.Quit
End If
Set xlApp = Nothing
Set xlWB = Nothing
Set xlSheet = Nothing
Set olItem = Nothing
End Sub
Sub TestJH()
Dim Element As Object ' HTMLButtonElement
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Dim Link As Object ' MSHTML.HTMLAnchorElement
Dim strCountBody As Object
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Dim Lurl As String
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
Range("B7").Activate 'This is the link that is found at B7: http://sar.paragonrels.com/publink/default.aspx?GUID=bc3565b3-4b55-46e1-94bf-b8b68ee32ada&Report=Yes
Lurl = ActiveCell.Value
ActiveCell.Offset(0, 1).Activate ' I want to paste the result in C7
IE.Visible = True
With IE
IE.Navigate Lurl
On Error Resume Next
Do While .ReadyState <> 4 Or .Busy
Application.Wait (1)
If Err.Number = -2147417848 Then Exit Do 'In case of client disconnect
Loop
On Error GoTo 0
'IE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
'IE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
' grab some text from the body
strCountBody = IE.Document.body.innerText
lStartPos = InStr(1, strCountBody, "View")
lEndPos = lStartPos + 1
TextIWant = Mid$(strCountBody, lStartPos, lEndPos - lStartPos)
ActiveSheet.Paste
End With
Set IE = Nothing
Loop
End Sub
Sub TestJH()
Dim Element As Object ' HTMLButtonElement
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Dim Link As Object ' MSHTML.HTMLAnchorElement
Dim strCountBody As String
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Dim Lurl As String
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
Range("B7").Activate 'This is the link that is found at B7: http://sar.paragonrels.com/publink/default.aspx?GUID=bc3565b3-4b55-46e1-94bf-b8b68ee32ada&Report=Yes
Lurl = ActiveCell.Value
ActiveCell.Offset(0, 1).Activate ' I want to paste the result in C7
IE.Visible = True
With IE
IE.navigate Lurl
On Error Resume Next
Do While .ReadyState <> 4 Or .Busy
Application.Wait (1)
If Err.Number = -2147417848 Then Exit Do 'In case of client disconnect
Loop
IE.navigate IE.document.frames.Item(3).Location
Do While .ReadyState <> 4 Or .Busy
Application.Wait (1)
If Err.Number = -2147417848 Then Exit Do 'In case of client disconnect
Loop
On Error GoTo 0
'IE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
'IE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
' grab some text from the body
strCountBody = IE.document.body.innerText
lStartPos = InStr(1, strCountBody, "View")
lEndPos = lStartPos + 1
TextIWant = Mid$(strCountBody, lStartPos, lEndPos - lStartPos)
ActiveCell = TextIWant
End With
IE.Quit
Set IE = Nothing
End Sub