' ______________________________________
'
' This macro removes tags such as < and >
' from a web page source code
' It works in Word
' ______________________________________
'
Dim MyRange As Range
Dim pos As Long
Set MyRange = ActiveDocument.Range
With MyRange.Find
Do While .Execute(findText:="(\<*\>)", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
MyRange.Delete
Loop
End With
Set MyRange = Nothing
MsgBox "end macro"
End Sub
'______________________________________
'Another way to do the same job of removing html tags from the source code of a web page is:
'______________________________________
Sub Remove_All_Tags()
'______________________________________
'
' This VBA macro removes all tags from
' the source code of a web page
' For example, "<b>This text</b>"
' becomes "This text"
' This quick macro works in Word
'______________________________________
'
ActiveDocument.Select
If Selection.Find.Execute("<", 0, 0) Or Selection.Find.Execute("</", 0, 0) = True Then
Do
Selection.Extend (">")
Selection.Delete
ActiveDocument.Select
Loop Until Selection.Find.Execute("<", 0, 0) = False
Else
MsgBox "No < > tag was found"
End If
End Sub