Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should take a focus on <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/util/XReplaceable.html" rel="noreferrer">XReplaceable</a> interface. Here is the example. Please note, that there's no error handling. I've tested it with LibreOffice writer and it works fine for me.</p> <pre><code>uses ComObj; procedure OpenOfficeReplace(const AFileURL: string; ASearch: string; const AReplace: string); var StarOffice: Variant; StarDesktop: Variant; StarDocument: Variant; FileReplace: Variant; FileParams: Variant; FileProperty: Variant; begin StarOffice := CreateOleObject('com.sun.star.ServiceManager'); StarDesktop := StarOffice.CreateInstance('com.sun.star.frame.Desktop'); FileParams := VarArrayCreate([0, 0], varVariant); FileProperty := StarOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue'); FileProperty.Name := 'Hidden'; FileProperty.Value := False; FileParams[0] := FileProperty; StarDocument := StarDesktop.LoadComponentFromURL(AFileURL, '_blank', 0, FileParams); FileReplace := StarDocument.CreateReplaceDescriptor; FileReplace.SearchCaseSensitive := False; FileReplace.SetSearchString(ASearch); FileReplace.SetReplaceString(AReplace); StarDocument.ReplaceAll(FileReplace); ShowMessage('Replace has been finished'); StarDocument.Close(True); StarDesktop.Terminate; StarOffice := Unassigned; end; </code></pre> <p>And the usage of the example</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); begin OpenOfficeReplace('file:///C:/File.odt', 'Search', 'Replace'); end; </code></pre> <p>There are also several search/replace options for <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchDescriptor.html" rel="noreferrer">SearchDescriptor</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload