SOLVED!

From: Roland Leisch (leisch_at_24speed.at)
Date: 02/15/05


Date: Tue, 15 Feb 2005 17:27:26 +0100

Roland Leisch wrote:

> Hello!
>
> I have the follwing problem: Im using a Java-COM Bridge and I try to add
> a custom property to a document (which is in an OLE container) and set a
> value for this property:
>
> Variant result = propertiesAutomation.invoke("add", new Object[]{
> new Integer(100), //Value = 100
> Variant.createUnspecifiedParameter(),
> new Integer(5), //Datatype 5 for Integer
> new Boolean(true), //LinkToContent
> "testproperty"}); //name of property
>
> The problem is that the property is created, but the value is "0.0". If
> I try to change the value later via setproperty method I get an
> 0x80020009; DISP_E_EXCEPTION!
>
> I have tried all values for datatype and different values but every time
> I get the same result.
>
> Im using a Java-COM Bridge to invoke Methods and Microsoft Office XP (in
> this codesample for Word XP).
>
> Can anyone be so kind and help me?
>
> best regards
>

I found the problem: the parameter list is inverted with this kind of
method call:

Variant result = propertiesAutomation.invoke("add", new Object[]{
                 Variant.createUnspecifiedParameter(), //LinkToSource
                 new Variant(100), //Value
                 new Variant(4), //Datatype 1-number, 2-Boolean, 3-Date,
4-String, 5-Float
                 new Variant(false), //LinkToContent
                 new Variant("m2n uri") //Name der Property
         });