Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

How to load MS Word documents into TX Text Control

This source code snippet requires TX Text Control ActiveX
Author:TX Text Control Support Department
Language:VBScript
Version:1.0
Released:November 10, 2004
Last modified:January 11, 2008
Requirements:TX Text Control ActiveX with Internet Explorer 5.5
Download code:tx_sample_activex_msword.zip Download [17.42 KB, ZIP]

How to load binary MS Word documents into TX Text Control

Click to enlarge

This sample application illustrates how to load binary files such as Microsoft Word documents into TX Text Control that is embedded in an HTML file.

Generally, you can use the Microsoft INET control to load documents into a variable. But it is not possible to load binary files such as Microsoft Word documents or the internal TX Text Control format.

Therefore, you can use the Microsoft XML Core Services (MSXML) to load a document using an HTTP GET command.

  1. Function GetFile(URL)
  2. Dim objXML
  3. Dim HTTPResponse
  4.  
  5. Set objXML = CreateObject("Msxml2.XMLHTTP")
  6.  
  7. Call objXML.Open("GET", URL, False)
  8. Call objXML.Send()
  9.  
  10. HTTPResponse = objXML.responseBody
  11.  
  12. Set objXML = Nothing
  13.  
  14. GetFile = HTTPResponse
  15. End Function

On a button, the GetFile() function is called with an URL as the parameter. The contents of the variable are used with TX Text Control's LoadFromMemory method.

  1. Sub Button1_OnClick
  2. Dim objDocument
  3. objDocument = GetFile("http://bin.textcontrolasp.com/sample_load_msword/demo.doc")
  4. objTX.LoadFromMemory objDocument, 9, false
  5. End Sub

To run this sample application, you need to be using Microsoft Internet Explorer 5.5 or newer. Other browsers (such as Firefox and Opera) are not supported.

Launch Sample Application
The demo downloads 2MB of data, pls be patient.

To use the downloadable version of this sample at least a TX Text Control ActiveX 11.0 trial version, Internet Explorer 5.5 and MSXML2 are required.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place