[Solved] Deplhi - Could not convert variant of type...

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Sk1X1
Posts: 2
Joined: Thu Sep 22, 2016 12:38 pm

[Solved] Deplhi - Could not convert variant of type...

Post by Sk1X1 »

Hello guys,
I'm trying to open LibreOffice from Delphi script. I read some articles and wrote this code:

Code: Select all

var
  FOffice, FDesktop, FDocument: Variant;
begin
  FOffice := CreateOleObject('com.sun.star.ServiceManager');
  FDesktop := FOffice.CreateInstance('com.sun.star.frame.Dekstop');
  OpenParams := VarArrayCreate([0, 0], varVariant);
  FDocument := FDesktop.LoadComponentFromURL('private:factory/swriter', '_default', 0, OpenParams);
end;
But when I try to run it, on the last line I get this error:

Code: Select all

Could not convert variant of type (Unknown) into type (Integer)
What am I doing wrong?
Thanks for all replies.
Last edited by Hagar Delest on Fri Sep 23, 2016 9:07 pm, edited 1 time in total.
Reason: tagged [Solved].
LibreOffice 5.1 on Win 10 64bit
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Deplhi - Could not convert variant of type...

Post by Zizi64 »

'com.sun.star.frame.Dekstop'
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Sk1X1
Posts: 2
Joined: Thu Sep 22, 2016 12:38 pm

Re: Deplhi - Could not convert variant of type...

Post by Sk1X1 »

Oh, I was looking into this code so long that I overlooked this :(
Thanks a lot!
LibreOffice 5.1 on Win 10 64bit
User avatar
robleyd
Moderator
Posts: 5056
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Deplhi - Could not convert variant of type...

Post by robleyd »

You might find this site or this other site handy for code reviews :lol:
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
Post Reply