LibreOffice, Writer, Macros, How to replace a embedded object formula with its string contents

48 Views Asked by At

I have a Open Office Writer document with math formulas (com.sun.star.formula.FormulaProperties) and i want to make a macro that replace that formula objects with its string contents.

I am very novice!

I can reach the formula objects with

Dim Objs As Object: Objs=ThisComponent.getEmbeddedObjects()

and its string contents with

Objs(i).Model.Formula

But I can not replace each other inside document.

1

There are 1 best solutions below

0
JohnSUN On

May be so?

Sub ConvertToText
Dim oEmbeddedObject As Variant
  For Each oEmbeddedObject In ThisComponent.getEmbeddedObjects()
      oEmbeddedObject.getAnchor().setString(oEmbeddedObject.getEmbeddedObject().Formula)
      oEmbeddedObject.dispose()
  Next 
End Sub