Adi Muntean Adi Muntean - 14 days ago 4x Question

setParameter for an array property with JACOB

I have the following VB code :

Set QuoteRequest = Quotes.Add
With QuoteRequest
.No = 1
End With

I use JACOB to access that COM object.

quoteRequest.setProperty("Code(0)", "NAME1");
quoteRequest.setProperty("Code(1)", "NAME2");

But this leads to exception Can't map to dispid: QuoteCode(0)

How can I pass that property?

import com.jacob.activeX.*;

static void setProperty(Dispatch d, String sName, String sIndex, String sValue) {
  Variant av[] = { new Variant(sIndex), new Variant(sValue) };
  Dispatch.invokev(d, sName, Dispatch.Put, av, NO_INT_ARGS).safeRelease();
  av[0].safeRelease(); av[1].safeRelease();

That's the code I used. Works for me, however I was doing some changes to Jacob, to force garbaging of unused variants. Hard to say what I exactly did, it was years ago :)