-
help on macro to replace html tags frontpage
trying to create a macro to replace HTML tags in frontpage 2000. Have the following code that works up to some point. I need to look for tags like <td &^&*^> and change them to <td> I also want to look for tags like
<P ALIGN="LEFT" DIR="LTR"> and take them out. Tags are not alwas the same so I would look for <p &^&*^*> and take it out. Any ideas?
[vba]Sub changetags()
lngViewMode = Application.ActivePageWindow.ViewMode
'Switch to Normal view.
Application.ActivePageWindow.ViewMode = fpPageViewNormal
Dim objElement As IHTMLElement
Dim strTagName As String
Dim strSearch As String
Dim strReplace As String
'Doctype
strPageHTML = ActiveDocument.DocumentHTML
'td
strReplace = "<td>"
strSearch = "<td" & "*" & " >"
strPageHTML = Replace(strPageHTML, strSearch, strReplace)
'F'ing Microsoft Tags
strSearch = "</p>"
strReplace = ""
strPageHTML = Replace(strPageHTML, strSearch, strReplace)
strSearch = "<P ALIGN=" & Chr(34) & "LEFT" & Chr(34) & " DIR=" & Chr(34) & "LTR" & Chr(34) & ">"
strReplace = ""
strPageHTML = Replace(strPageHTML, strSearch, strReplace)
ActiveDocument.DocumentHTML = strPageHTML
Application.ActivePageWindow.ViewMode = lngViewMode
End Sub[/vba]
Last edited by Aussiebear; 03-11-2011 at 01:59 PM.
Reason: Applied VBA tags to code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules