Sometimes user need to preview text files like .txt/.rtf/.vp in VSPrint8 control. This blog explains the small and easy implementation of the same.

One can embed VSPrint in a HTML page. This can further used to load and preview Text files (.txt, .rtf, .vp). For this implementation, one need to open a notepad or any other text editor and copy the code below.

<html>
<head>
<title>VSPrinter8 URL</title>
</head>
//Adding buttons using VBScript
<script language=vbscript>
Sub btnLoadText_OnClick()
vp.URL = "readme.txt" 'Specifies the URL of a Text File
End Sub

Sub btnLoadRTF_OnClick()
vp.URL = "PicExp.rtf" 'Specifies the URL of a RTF File
End Sub

Sub btnLoadVP_OnClick()
vp.URL = "PicExp.vp" 'Specifies the URL of a vsprint (.vp) File
End Sub
</script>
// Embedding VSPrint Object in Html

<body>
<p>This is a <b>VSPrinter8</b> control:</p>
<p>
<object classid="clsid:A8561647-E93C-11D3-AC3B-CE6078F7B616" id=vp width=250 height=350>
</object>
</p>
<p>
1: <input type=button value="Load Text File" name=btnLoadText><br>
2: <input type=button value="Load RTF File" name=btnLoadRTF><br>
3: <input type=button value="Load VSPrint Document" name=btnLoadVP><br>
</p>
</body>
</html>


Now save this file as .htm or .html and then run the same in IE, as ActiveX controls are specifically meant to run on IE.

For complete implementation, refer to the attached htm file.
Download Sample