That is a complex task. You will find enough information how to read a formula from a cell or write a formula. Here some additions for the Math object. The code is not ready to use, but shows you some solutions.

The first one is for first time writing the Math objects.

```
sub AddMathToCell(byval nCol as long, byval nRow as long, byval nSheet as long)
rem Make sure it is a spreadsheet document and sheet exists
dim oDoc as variant: oDoc=thisComponent
dim sDocType as string: sDocType = oDoc.Identifier
if sDocType <> "com.sun.star.sheet.SpreadsheetDocument" then
msgbox "Only for spreadsheets"
exit sub
end if
dim oSheets as variant: oSheets = oDoc.Sheets
if oSheets.count <= nSheet then
msgbox "Sheet does not exists"
exit sub
end if
dim oOneSheet as variant: oOneSheet = oSheets.getByIndex(nSheet)
dim oOneCell as variant: oOneCell = oOneSheet.getCellByPosition(nCol,nRow)
dim oDrawPage as variant: oDrawPage = oOneSheet.DrawPage
dim oMathOLE as variant: oMathOLE = oDoc.createInstance("com.sun.star.drawing.OLE2Shape")
dim oPos as new com.sun.star.awt.Point
Dim oSize as new com.sun.star.awt.Size
oPos.x = oOneCell.Position.X
oPos.y = oOneCell.Position.Y
oMathOLE.Position = oPos
oSize.Width = oOneCell.Size.Width
oSize.Height = oOneCell.Size.Height
oMathOLE.Size = oSize
oMathOLE.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997"
oDrawPage.add(oMathOLE)
dim oMathDoc as variant: oMathDoc = oMathOLE.Model
dim sFormel as string: sFormel ="{a^2-b^2}over{a-b}"
oMathDoc.Formula = sFormel
oDoc.Modified = true
end sub
```

The second one is for accessing the existing Math objects.

```
sub ShowAllMathFormulas(byval nSheet as long)
rem Make sure it is a spreadsheet document and sheet exists
dim oDoc as variant: oDoc=thisComponent
dim sDocType as string: sDocType = oDoc.Identifier
if sDocType <> "com.sun.star.sheet.SpreadsheetDocument" then
msgbox "Only for spreadsheets"
exit sub
end if
dim oSheets as variant: oSheets = oDoc.Sheets
if oSheets.count <= nSheet then
msgbox "Sheet does not exists"
exit sub
end if
dim oOneSheet as variant: oOneSheet = oSheets.getByIndex(nSheet)
dim oDrawPage as variant: oDrawPage = oOneSheet.DrawPage
dim nDrawObjectCount as integer: nDrawObjectCount = oDrawPage.count
dim i as integer
dim oShape as variant
dim oModel as variant
dim sMathFormula as string
for i = 0 to nDrawObjectCount - 1
oShape = oDrawPage.getByIndex(i)
if oShape.supportsService("com.sun.star.drawing.OLE2Shape") then
if oShape.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" then
rem It is a formula object
oModel = oShape.model
sMathFormula = oModel.formula
msgbox(sMathFormula)
else
rem external OLE do not have a model, but all have a CLSID
msgbox(oShape.CLSID)
end if
else
msgbox(oShape.ShapeType)
end if
msgbox(oShape.Anchor.AbsoluteName)
next i
end sub
```

It is not clear, what you want to do. Calc formulas are for calculating with numbers and texts. Math is for typesetting formulas and do not have a 'result'. If you want that the formula contained in cell A1 is shown in cell A2, you would write in A2

`=formula(A1)`

. There is no Math involved.thanks for answering!. From A Libreofficebasic or java macro I want to 1. read the formula in cell A1 "pi()/64*(D_e^4-d_i^4)" 2. translate in a string that Math can understand "%pi over 64 cdot (D_e^4-d_i^4)" 3. send to Libreoffice Math 4. receive the object and attach over cell A2. I want to make it with macro in order to refresh the many formulas of my sheet every time i need it without doing the job by keyb. and mouse.

for anybody intersted https://wiki.documentfoundation.org/i... is an up to date guide for libreoffice 4.1x