PDA

View Full Version : problem: saving as word doc in v10 trial


Unregistered
October 28, 2002, 17:55:00
Hi -

I'm having difficulty saving documents from the text control in Microsoft Word .DOC format. Has anyone run into this problem with the trial version, and if so, how did you solve it?

I am using the Version 10 ActiveX Text Control on a webpage that uses JavaScript (instead of VBScript) to perform the various control's operations, and I'm using Internet Explorer 5.5. My web docs are being loaded through Apache Tomcat 4.1 on a Windows 2000 system, although I don't think that should make any difference with this problem.

When a user decides to save their document, they click a button that calls the javascript function processData(). Here is my processData() function so far (note that I've reduced its functionality for debugging purposes):
function processData()
{
var doc_data = "";
// doc_data = document.all.objTX.saveToMemoryBuffer(doc_data, 5, 0); // RTF
doc_data = document.all.objTX.saveToMemoryBuffer(doc_data, 9, 0); // DOC
alert(doc_data);
}
Note that I've commented out the statement that would save the control's text in RichText format (which works, by the way). When I change the filter field from 5 (RTF) to 9 (DOC), I get an error stating "Invalid property value." Last I checked, the DOC filter is included in the trial version of the control, so why doesn't this work?

I also tried the following, which also doesn't work:
function processData()
{
var doc_data = new Array();
doc_data = document.all.objTX.saveToMemory(9, 0);
alert(typeof doc_data);
alert(doc_data.toString());
}
As I understand it, this should work because a) JavaScript uses untyped variables (so we shouldn't have to declare the array as Byte as you would have to in VBScript), and b) saveToMemory() does the same thing as saveToMemoryBuffer() only the data is stored in array form instead of a string. But when I run this code, the first alert() box displays "unknown" (indicating that whatever saveToMemory returns is unrecognized by JavaScript) and the second triggers an error stating "Object expected." I've tried various ways of typecasting and converting the return value of saveToMemory, but always in vain.

So anyway, that should be enough information to go on. Any ideas as to what I'm doing wrong here?

Thanks -

Matt


This message was originally posted by Matt Storer in the old TX Text Control Support Forum.

Meik Dankleff
October 28, 2002, 19:41:52
Matt,

I couldn't manage to get this working in JavaScript as well. The type of doc_data is not recognized by TX, that's why you get the error message. In VBScript it's no problem to do this, because all variables are initialized as variants which are recognized by TX. If you want to use JavaScript for the rest of your code, you can mix the two models.

Here is a code snippet in VBScript that copies the contents of a TX to another TX using SaveToMemoryBuffer and Word format:

Sub Button_OnClick
data = objTX.SaveToMemoryBuffer(data, 9, 0)
objTX2.LoadFromMemory data, 9, 0
End Sub

This message was originally posted by Meik Dankleff in the old TX Text Control Support Forum.