Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliSeconds As Long)
at the very beginning of the VBA Module you add the code to (before any procedure or function declaration).
Sub CheckForClosed()
Static Web As InternetExplorer
Dim pos0, pos1 As Integer
Dim str, c As String
Dim Sel
Dim ml As MailItem
Dim q#, del#, sol#
Dim isArticle As Boolean
If Web Is Nothing Or TypeName(Web) <> "IWebBrowser2" Then Set Web = CreateObject("InternetExplorer.Application")
' Web.Visible = True
Set Sel = myOlEEItems
If Outlook.ActiveExplorer.Selection.Count > 0 Then
If TypeName(Outlook.ActiveExplorer.Selection.item(1)) = "MailItem" Then
Set Sel = Outlook.ActiveExplorer.Selection
End If
End If
For Each ml In Sel
str = ""
On Error Resume Next
str = ml.UserProperties("Reference")
q# = q# + 1
On Error GoTo 0
If str <> "" Then
isArticle = (Left(str, 1) = "A")
If isArticle Then
str = "http://e-e.com/viewArticlePrinterFriendly.jsp?articleID=" & Mid$(str, 3)
Else
str = "http://e-e.com/viewQuestionPrinterFriendly.jsp?qid=" & Mid$(str, 3)
End If
Web.Navigate (str)
While Web.ReadyState <> READYSTATE_COMPLETE: Sleep 10: Wend
str = LCase(Left$(Web.Document.Body.InnerHtml, 2000))
If isArticle Then
str = Mid$(str, InStr(str, "<div class=""postabletype"">") + Len("<div class=""postabletype"">"))
Else
str = Mid$(str, InStr(str, "<div class=""questiontype"">") + Len("<div class=""questiontype"">"))
End If
str = Left$(str, InStr(str, "</div>") - 1)
str = Trim(Replace(str, Chr(10), ""))
c = "."
If str = "solution" Then ml.Delete: sol# = sol# + 1: c = "+"
If str = "<span style=""color: #ff0000"">deleted</span> question" Then ml.Delete: del# = del# + 1: c = "-"
If str = "<span style=""color: #ff0000"">deleted</span> article" Then ml.Delete: del# = del# + 1: c = "-"
Debug.Print c;
End If
Next
Debug.Print Chr(13) & "Q: " & q# & " Solved: " & sol# & " Deleted: " & del#
Web.Quit
Set Web = Nothing
End Sub
To use the code, I recommend to create a toolbar button, and assign the macro call to it. I have created this one for Outlook 2003:
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Author
Commented: