I'm working on some code to paste into the currently active OpenOffice document directly from C#. I can't include any of the OpenOffice libraries, because we don't want to package them, so we're using reflection to get access to the OpenOffice API.
My question involves using a dispatcher through reflection. I can't figure out the correct parameters to pass to it, giving me a lovely "TargetInvocationException" due to mismatched types.
object objframe = GetProperty<object>(objcontroller, "frame");
if (objframe != null)
{
object[] paramlist = new object[2] {".uno:Paste", objframe};
InvokeMethod<object>(objdispatcher, "executeDispatch", paramlist);
}
How can I fix it?
Is it just me or are your parameters the wrong way around? Also, do you have the right number of parameters? I could be missing something though, so sorry if you've already checked this stuff:
The documentation says:
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
Which would indicate to me that you need to have your parameter list defined as
object[] paramlist = new object[5] {objframe, ".uno:Paste", "", 0, null};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With