I am doing some powerpoint shape building using Jacob from Java, and I am stuck on something that might be trivial, but I cannot make it work. I need to create a rectangle and change its Fill color. Here is the code from powerpoint application creation up to the change of color I want to perform.
ActiveXComponent objPPT = new ActiveXComponent("PowerPoint.Application");
objPPT.setProperty("Visible",new Variant(true));
Variant presentations = objPPT.getProperty("Presentations");
Variant presentation = Dispatch.call(presentations.getDispatch(), "Add");
Variant slides = Dispatch.get(presentation.getDispatch(), "Slides");
Variant slide = Dispatch.call(slides.getDispatch(), "Add",1, 12);
Variant shapes = Dispatch.get(slide.getDispatch(), "Shapes");
Variant rectangle= Dispatch.call(shapes.getDispatch(), "AddShape", 1, 15, 1, 20, 8);
Variant rectangleFill = Dispatch.get(effectivity.getDispatch(), "Fill");
Variant rectangleFillForeColor = Dispatch.get(rectangleFill.getDispatch(), "ForeColor");
// there I would need to create Variant rgb = RGB(10, 10, 10)
Dispatch.Put(rectangleFillForeColor.getDispatch(), "RGB", rgb);
As you can see, I miss the creation of rgb Variant (Long type underneath)
That Long value is returned by a call to RGB function (which itself take red, green and blue value as input.)
https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/rgb-function
and my problem is the following : I know how to call methods on components using Jacob (Dispatch.call) but I never called an actual function.
Do anyone knows how to do that ? Just to be clear, I know I could somehow bypass the call to RGB by computing the Long value by myself (the value is red+256*(green+256*blue)), but I am really curious about how to make a RGB call work using Jacob, just in case this happens again on a less trivial function someday :)