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

Java, C++, C#, Delphi, ??? - Using the UNO bridges

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

Postby Sk1X1 » Thu Sep 22, 2016 12:54 pm

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

Code: Select all   Expand viewCollapse view
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   Expand viewCollapse view
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
Sk1X1
 
Posts: 2
Joined: Thu Sep 22, 2016 12:38 pm

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

Postby Zizi64 » Thu Sep 22, 2016 4:33 pm

'com.sun.star.frame.Dekstop'
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.3.3; AOO4.1.6
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.
User avatar
Zizi64
Volunteer
 
Posts: 8537
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Postby Sk1X1 » Fri Sep 23, 2016 8:32 am

Oh, I was looking into this code so long that I overlooked this :(
Thanks a lot!
LibreOffice 5.1 on Win 10 64bit
Sk1X1
 
Posts: 2
Joined: Thu Sep 22, 2016 12:38 pm

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

Postby robleyd » Fri Sep 23, 2016 9:13 am

You might find this site or this other site handy for code reviews :lol:
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 3057
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia


Return to External Programs

Who is online

Users browsing this forum: No registered users and 3 guests