I read the documentation of OpenOffice.org BASIC. Tried using the Doc.createReplaceDescriptor to replace a piece of text in a textbox in a libreoffice writer macro ( replace “two” by “2” ) but I realized it does not work with the text box. When I inserted “two” out of the textbox, it worked fine!!! Please can someone tell me if there is a way of making it work with text box?
The file containing the textbox was created out of the macro ( it is in a file I had created and saved before using libreoffice writer then opened to change “two” into “2”). Here is the piece of code in charge of that
Sub insertDataIntoTemplate(Optional pDoc As Object)
REM Reworked to also run in very old versions.
If IsMissing(pDoc) Then
theDoc = ThisComponent
Else
theDoc = pDoc
End If
docUrl = theDoc.URL
If NOT FileExists(docUrl) Then
MsgBox("The document must be saved to an URL for this routine to work.")
Exit Sub
End If
If NOT theDoc.supportsService("com.sun.star.text.TextDocument") Then
MsgBox("This routine can only export Writer documents.")
Exit Sub
End If
Dim Replace As Object
Dim oTextField As Object
Replace = pDoc.createReplaceDescriptor
Replace.SearchString = "two"
Replace.ReplaceString = "2"
pDoc.replaceAll(Replace)
End Sub