0

On OpenOffice documentation [1], I found a replace example. But I didn't find a search example.

Dim Doc As Object
Dim Sheet As Object
Dim ReplaceDescriptor As Object
Dim I As Integer

Doc = ThisComponent
Sheet = Doc.Sheets(0)

ReplaceDescriptor = Sheet.createReplaceDescriptor()
ReplaceDescriptor.SearchString = "is"
ReplaceDescriptor.ReplaceString = "was"
For I = 0 to Doc.Sheets.Count - 1
   Sheet = Doc.Sheets(I)
   Sheet.ReplaceAll(ReplaceDescriptor) 
Next I

And better: Where can I find the docs that list the range/cell possible methods?

[1] http://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Editing_Spreadsheet_Documents

Josir
  • 1,282
  • 22
  • 35

1 Answers1

0

first of all: https://wiki.openoffice.org/wiki/Extensions_development_basic is a good starting point. In particular the XRAY tool is very helpfully.

The following code shows a search example:

Dim oDoc As Object
Dim oSheet As Object
Dim oSearchDescriptor As Object
Dim i As Integer

oDoc = ThisComponent
oSheet = oDoc.Sheets(0)

oSearchDescriptor = oSheet.createSearchDescriptor()
oSearchDescriptor.SearchString = "is"
For i = 0 to oDoc.Sheets.Count - 1
   oSheet = oDoc.Sheets(i)
   oResults = oSheet.findAll(oSearchDescriptor)
   'xray oResults
   if not isnull(oResults) then msgbox oResults.AbsoluteName
Next i

If you have XRAY installed, you can inspect every object with it and you have access to the related API docs.

Greetings

Axel

Axel Richter
  • 56,077
  • 6
  • 60
  • 87
  • 1
    Thanks for replying Axel. I do use XRAY - but there are so many methods and properties that it's very difficult to find a specific one. Besides, due to class inheritance, the documentation is very granular and don't show ALL possible methods of a specific class. Anyway, I will try your solution as soon as possible. – Josir Aug 11 '14 at 15:52