Uber Schincariol Guest
|
Posted: Tue Feb 03, 2004 8:53 am Post subject: Write and delphi width ole |
|
|
Hi everybody
I’ve integrated Write by OpenOffice in a Delphi program. With 1.0.3. version I just succeeded in “controlling” Write in order to have searches/replacements inside the decument exploiting OLE.
Now I’ve updated OpenOffice with 1.1.0 version, and the function that was causing me problems before is detecting me some incompatibilities.
The function is:
xReplaceDescr := Document.createReplaceDescriptor(); (non tradurre)
Could somebody help me, please?
You can find the code hereby:
procedure TFEditPreventivo.TB_Off(Sender: TObject);
var
f : string;
ID : integer;
// VARIABILI PER IL CONTROLLO OLE DI OPEN OFFICE
StarOffice , StarDesktop, Document,xFound, xReplaceDescr : Variant;
OK : Boolean;
i : integer;
begin
StarOffice := CreateOleObject('com.sun.star.ServiceManager');
f:='c:\documento.sxw';
for i:=1 to Length(f) do
if f[i]='\' then f[i]:='/';
OK := not (VarIsEmpty(StarOffice) or VarIsNull(StarOffice));
if OK then
begin
StarDesktop := StarOffice.createInstance('com.sun.star.frame.Desktop');
Document := StarDesktop.LoadComponentFromURL( 'file:///'+f, '_blank', 0, VarArrayCreate([0, - 1], varVariant));
OK := not (VarIsEmpty(Document) or VarIsNull(Document));
if OK then
begin
// ******** ERROR ERROR ERROR ERROR ERROR ERROR *********
xReplaceDescr := Document.createReplaceDescriptor();
// ******** ERROR ERROR ERROR ERROR ERROR ERROR *********
xReplaceDescr.SearchString := '@@_DATA';
xReplaceDescr.ReplaceString := DateToStr(now);
xFound := Document.replaceAll( xReplaceDescr );
end
else
MessageDlg('Impossibile caricare il documento richiesto', mtError, [mbOK], 0);
StarOffice := Unassigned;
end
else
MessageDlg(
'Impossibile connettersi ad open Office',
mtError, [mbOK], 0);
finally
StarOffice := Unassigned;
StarDesktop:= Unassigned;
Document:= Unassigned;
xReplaceDescr:= Unassigned;
xFound:= Unassigned;
end;
end; |
|