Macro - How to select text in a table cell and use that to replace other text in a document

Using a macro, how do I select text in a table (ie A1) and use that string to replace another string in the same document.
I find the Basic programming documentation quite hard to search and interpret

Churs

For Calc, or Writer?..
A file with an example of what you want always helps anyone who wants to help you.

It is for writer.
I have been reading quite a bit on the OO site and when using
Cell.getValue() it returns the floating point value but not the text

https://www.openoffice.org/api/docs/common/ref/com/sun/star/table/XCell.html

I’ll post the macro when I get home


Here is the macro. If no table is in writer it will create one and if the table is already there it get deleted. Should work on a blank document.
However, I cannot read a cell back
Any suggestions

Sub InsertDeleteTable Dim oTable 'Newly created table to insert Dim oTables 'All of the text tables Dim oInsertPoint 'Where the table will be inserted Dim sTableName as String

sTableName = “TableCustomerInfo”
oTables = ThisComponent.TextTables

If oTables.hasByName(sTableName) Then
oTable = oTables.getByName(sTableName)

REM Although this seems like the correct way to remove text content,
REM what if the table is not inserted into the primary document's
REM text object? oTable.dispose() may be safer to use.
ThisComponent.Text.removeTextContent(oTable)

Else

REM Let the document create the text table.  

oTable = ThisComponent.createInstance( “com.sun.star.text.TextTable” )
oTable.initialize(2, 3) 'Two rows, three columns

REM If there is a bookmark named "InsertTableHere", then insert
REM the table at that point. If this bookmark does not exist, 
REM then simply choose the very end of the document.

If ThisComponent.getBookmarks().hasByName(“InsertTableHere”) Then
oInsertPoint =_
ThisComponent.getBookmarks().getByName(“InsertTableHere”).getAnchor()
Else
oInsertPoint = ThisComponent.Text.getEnd()
End If

REM Now insert the text table at the end of the document.
REM Note that the text object from the oInsertPoint text
REM range is used rather than the document text object.

oInsertPoint.getText().insertTextContent(oInsertPoint , oTable, False)

REM The setData() object method works ONLY with numerical data.
REM The setDataArray() object method, however, also allows strings.


oTable.setDataArray(Array(Array("A0", "B0", "C0"), Array("A1", "B1", "C1")))

oTable.setName(sTableName)
End If
'--------------------------------------------
'replace text
Dim newText(1) as String
Dim oldText as String

newText =  oTable.getDataArray(A1)

msgBox (newText)

End Sub

In addition to XCell, the cell objects in Writer also expose XTextRange interface, with its getString().

You may use tools like MRI/XRay, or you may use the integrated Watch tool, using which, you may expand Types under a watched variable, and see all types and methods and much more for any variable.

Primo, didn’t know about XTextRange.
Is there a good basic writeup about MRI anywhere ?

Hmm, MRI is refusing to load on Version: 6.0.5.2 (x64) win10.
(com.sun.star.uno.RuntimeException) { { Message = "<class ‘SyntaxError’>: invalid syntax (MRI.py, line 21), traceback follows\X000a File “C:\Program Files\LibreOffice\program\pythonloader.py”, line 149, in writeRegistryInfo\X000a mod = self.getModuleFromUrl( locationUrl )\X000a File “C:\Program Files\LibreOffice\program\pythonloader.py”, line 102, in getModuleFromUrl\X000a codeobject = compile( src, encfile

Personally I don’t use MRI, so cannot suggest any advise; problems in it should go to its bug tracker.

I prefer the built-in watch to look into objects.