Re: INFO: How to access Aspose.Word from COM clients


#1

Thank you for this great post! Everything is clear and straightforward except for the part about enumerations. Can you provide a very simple example of how enumerations would function and work in classical ASP?


#2

You simply have to use enumeration values (0, 1, 2 ...) instead of the names (SaveFormat.FormatDocument, SaveFormat.FormatText ...). How to obtain these values? Export the type library (with tlbexp.exe) and view it (for example, with MS Visual Basic 6). Here is an example for the SaveFormat enumeration:

SaveFormat_FormatDocument = 0,

SaveFormat_FormatText = 1,

SaveFormat_FormatAsposePdf = 2,

SaveFormat_FormatHtml = 3


#3

So instead of SaveFormat.FormatDocument, it would be SaveFormat.0 in classical ASP?

I was worried that enumerations were dynamic and were a real hassle but it sounds like that the values are static. I guess someone can post all the values and maintain an enumerations reference guide.

I just tried searching/running tlbexp.exe but it’s not on my Windows 2003 box. I guess I need to install the .NET SDK then? Maybe someone can beat me to posting all the enumeration values for Classical ASP…Stick out tongue


#4


So instead of SaveFormat.FormatDocument, it would be SaveFormat.0 in classical ASP?

No. You should simply use 0 instead of SaveFormat.FormatDocument.

I guess I need to install the .NET SDK then?

Yes, tlbexp.exe is a .NET SDK tool as described above.

I guess someone can post all the values and maintain an enumerations reference guide.

Hmm... Okay, I will probably post it here a bit later. Maybe it will be just the most important enums.


#5

Thank you very much!

One last question to clear things up, is this correct usage of an enumeration in classical ASP?

Set Builder = CreateObject(“Aspose.Word.DocumentBuilder”)

Builder.Document = Doc

Builder.Font.Size = 48

Set Enumeration = CreateObject(“Aspose.Word.Underline”)

Enumeration.1 = TRUE (or 1)

Builder.Writeln “This text in this line will be underlined.”


#6

You do not need to create enumeration objects at all. Imagine that we have this line in .NET code:

Builder.Font.Underline = Underline.Single;

Actually this code sets the Builder.Font.Underline property to integer value 1 (see in the listing). In COM/ASP we have to do it explicitly:

Builder.Font.Underline = 1

So this is how your code should look like:

Set Builder = CreateObject(“Aspose.Word.DocumentBuilder”)

Builder.Document = Doc

Builder.Font.Size = 48

Builder.Font.Underline = 1

Builder.Writeln “This text in this line will be underlined.”