views:

45

answers:

1

I am trying to use Aspose.Words library through COM Interop. There is one critical problem: I cannot set color. It is supposed to work by assigning to DocumentBuilder.Font.Color, but when I try to do it I get OLE error 0x80131509. My problem is pretty much like this one.

update:

Code Sample:

from win32com.client import Dispatch
Doc = Dispatch("Aspose.Words.Document")
Builder = Dispatch("Aspose.Words.DocumentBuilder")
Builder.Document = Doc
print Builder.Font.Size
print Builder.Font.Color

Result:

12.0
Traceback (most recent call last):
  File "aaa.py", line 6, in <module>
    print Builder.Font.Color
  File "D:\Python26\lib\site-packages\win32com\client\dynamic.py", line 501, in __getattr__
    ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2146233079, 'OLE error 0x80131509', None, None)

Using something like Font.Color = 0xff0000 fails with same error message

While this code works ok:

using Aspose.Words;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Font.Color = System.Drawing.Color.Blue;
            builder.Write("aaa");
            doc.Save("c:\\1.doc");
        }
    }
}

So it looks like COM Interop problem.

A: 

Hi. Please, check the answer provided here: http://www.aspose.com/community/forums/thread/240901/create-a-pivot-table-from-multiple-data-ranges.aspx I think, this approach should help you to resolve the problem.

alexey
Thansk for answer. Looks like that it will be possible to create generic function like SetColor(object, propertyname, color) using .NET Reflection.
Maxim