VBA code to convert html to plain text,  this helps us to make the html code readable by stripping all the html tags from the html code and printing/rendering the output of the code. When we have a an Excel sheet with cells containing html. We can batch convert them to plain text. It is possible to remove useless tags and styles from the html  and get the plain text out on the display screen so that it is easy to read for the person who does not know the html language and it also helps in portability of the text.

Referencing to “Microsoft HTML Object library”

As we use the Microsoft HTML  Object Library for the conversion of html code to plain text

Below is a code to convert html to plain text in VBA:

Public Function HtmlToText(ByVal sHTML As String) As String
	Dim iDoc As HTMLDocument
Dim result As String
	Dim paragraphs() As String
	If IsNull(sHTML) 
	Then
		HtmlToText = ""
	Exit Function
End If
result = ""
paragraphs = Split(sHTML, "")
For Each paragraph In paragraphs
	Set iDoc = New HTMLDocument
	iDoc.body.innerHTML = paragraph
	result = result & Chr(10) & Chr(10) & iDoc.body.innerText
	Next paragraph
	HtmlToText = result
End Function

Hope this is helpful when you want to convert html  to plain text. Leave your comments if you like the solution.