We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem when using Aspose.Words through COM

I described my question here:


It is essentially the same problem like this one:


But there is no solution in that thread.

This message was posted using Aspose.Live 2 Forum


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your interest in Aspose.Words. The problem occurs because Font.Color expects value of System.Drawing.Color type. But you cannot use this type in COM Interop. As a very simple solution, you can create a simple wrapper, which will allow setting color. To achieve this follow the instructions:

1. Open Visual Studio and create “Class Library” project.

2. Create method, which accepts two parameters (DocumentBuilder and color name.) Here is source code of the wrapper:

using System.Drawing;

using Aspose.Words;

namespace AsposeComWrapper


public class Methods


public void SetFontColor(object builder, object colorCode)


DocumentBuilder b = (DocumentBuilder) builder;

b.Font.Color = Color.FromName(colorCode.ToString());




3. Now, you should make your class library signed and visible for COM.

4. After building the project, you should register the DLL using the following command:

regasm /codebase AsposeComWrapper.dll

5. Once your helper DLL is registered, you can use it to set color. Here is sample code:

Dim lic

Set lic = CreateObject("Aspose.Words.License")


' Open document

Dim doc

Set doc = CreateObject("Aspose.Words.Document")

' Create DocumentBuilder.

Dim builder

Set builder = CreateObject("Aspose.Words.DocumentBuilder")

builder.Document = doc

dim helper

Set helper = CreateObject("AsposeComWrapper.Methods")

helper.SetFontColor builder, "Red"

builder.Write("Hello world!!!")

' Save output document


Hope this helps.

Best regards.