Hi everyone,
I've been trying to work with OpenOffice text documents from Delphi 5 in XP.
On the Internet I've found code to open a new document in
OpenOffice, but the instructions to open an existing document don't
seem to work.
Anyone out there working with OpenOffice text documents?
The code I've found is:
unit Unit1;
interface
uses
..., ComObj;
type
TsampleCode = class
function CreateTextDocument ( FN : string ) : Variant;
private
{ Private declarations }
public
{ Public declarations }
end;
...
implementation
var
Sample : tSampleCode;
function TsampleCode.CreateTextDocument ( FN : string ) : Variant;
var
ServiceManager: Variant;
StarDesktop: Variant;
Document: Variant;
begin
ServiceManager := CreateOleObject('com.sun.star.ServiceManager');
StarDesktop := ServiceManager.createInstance('com.sun.star.frame.Desktop');
Document := StarDesktop.LoadComponentFromURL(FN,
'_blank',0,VarArrayCreate([0,-1],varVariant));
CreateTextDocument := Document;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MyFile : string;
begin
MyFile := 'private:factory/swriter'; { successfully opens
OpenOffice with a new , empty document}
MyFile := 'file:///c:/temp/TestOO.sxw'; { fails to open TestOO.sxw}
Sample.CreateTextDocument(MyFile);
end;
Using 'file:///c:/temp/TestOO.sxw' to try to open the existing file
I created there results in a run-time error: "URL seems to be an
unsupported one". Yet the (sparce) documentation I've found on the
Internet indicates that existing files are to follow that format:
begin with "file:///" and follow with the full path/filename, but with
backslashes changed to forward slashes.
So my question is: What is the proper format to specify an
existing file? Any and all help greatly appreciated! (Also, if
you've done this, then pointers on how to use Delphi to insert text
would also be appreciated.)
Many thanks,
-- Stan
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi