Solved

Using Delphi to automate LibreOffice?

Posted on 2013-11-25
1
2,898 Views
Last Modified: 2013-11-27
I wrote a program in Delphi XE2 that opens an OpenOffice spreadsheet, inserts some data, formats it & then prints it. It worked fine, albeit slowly.

I've just uninstalled OpenOffice (3.3) & installed LibreOffice (4.1.3.2). Now I get an error message:

Invalid class string progid com.sun.star.ServiceManager

I've tracked it down to the 6th line of this procedure:
procedure ConnectOpenOffice;
begin
  if IsOpenOfficeConnected then exit;
  Screen.Cursor:= crHourglass;      Application.ProcessMessages;
  try
    OpenOffice:=        CreateOleObject('com.sun.star.ServiceManager'); // <---- This line
    if isNullEmpty(OpenOffice) then    Raise EOOoError.Create(OOo_connectKO);
    StarDesktop:=       CreateUnoService('com.sun.star.frame.Desktop');
    disp:=              CreateUnoService('com.sun.star.frame.DispatchHelper');
    OOoIntrospection:=  CreateUnoService('com.sun.star.beans.Introspection');
    OOoReflection:=     CreateUnoService('com.sun.star.reflection.CoreReflection');
  finally
    Screen.Cursor:= crDefault;
  end;
end;

Open in new window

Not sure what to do next, as the above code is in this file:

unit OOoTools;

{
This unit is part of a toolbox to pilot OpenOffice.org from Delphi using COM Automation.
Copyright (C) 2004-2007  Bernard Marcelly
This unit is free software; you can redistribute it and/or modify it under the terms of
the GNU Lesser General Public License as published by the Free Software Foundation;
either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this
library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
}
0
Comment
Question by:alex_smith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
alex_smith earned 0 total points
ID: 39680035
Found solution on https://forum.openoffice.org/en/forum/viewtopic.php?f=101&t=41778 
by RoryOF » Wed Jun 15, 2011 1:32 pm

In that case, I suggest removing LibreOffice and OpenOffice traces using Revo Uninstaller at its most aggressive settings, then reinstalling LibreOffice.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question