CodeItBetter Programming Another VB Programming Blog

How to convert HTML code to Txt

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'System & API - How to convert HTML code to Txt
'Windows API/Global Declarations for Best HTML to TXT Converter(5 Lines!!)
'You need to reference "Microsoft HTML Object Library"
' HTML to TXT Converter
' Description:Converts HTML Strings to TXT Strings Removing all HTML Code
' Returns: String

Public Function CleanHTML(TheHTML As String) As String
    Dim HtmlDOC As New HTMLDocument
    HtmlDOC.body.innerHTML = TheHTML
    CleanHTML = HtmlDOC.body.innerText
    Set HtmlDOC = Nothing
End Function
 
'How to call this function
'Debug.Print CleanHTML("<br><table border=0 width= valign=top cellpadding=2 cellspacing=7><tr><td 
'valign=top><a href=" & """http://news.google.com/news/url?sa=T&ct=us/1-
'0&fd=R&url=http://www.washingtonpost.com/wp-
'dyn/content/article/2006/02/25/AR2006022500227.html&cid=0" & "><b>Google's</b> Latest Bundle of 
'Goodies Is Worth Opening</a><br><font size=-1><font color=#6f6f6f>Washington Post,&nbsp;United 
'States&nbsp;-</font> <nobr>10 hours ago</nobr></font><br><font size=-1><b>...</b> <b>RSS</b> feeds 
'let you know when fresh content appears on washingtonpost.com pages that interest <b>...</b> 
'Unlike many Internet freebies, <b>Google</b> Pack delivers genuine value. <b>...</b>  
'</font><br></table>")
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.