Material für den Leistungskurs Jgst. Q2



Dieses Makro wandelt einen Text in eine Formel um:     
Sub S_insert_formula_from_selection   
odoc = Thiscomponent
        ocurrentselection = odoc.currentselection(0)
        if ocurrentselection.String = "" then
           msgbox "Erst Text auswählen"
           exit sub
        endif
        otext = odoc.Text
        ocursor = otext.createTextCursorByRange(ocurrentselection)
        sformula = ocursor.string
        ocursor.string = ""
        opage = odoc.drawpage
        oShape = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
        oShape.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997"
        oshape.AnchorType = 1
        oText.insertTextContent(oCursor, oShape, FALSE)
        oShape.Model.Formula = sformula
        oXEO = oShape.ExtendedControlOverEmbeddedObject
        oXEO.changeState(3)
        oXEO.changeState(1)
        oshape.VertOrientPosition = 0
        oshape.LeftMargin = 0 'Abstand auf null stellen
        oshape.RightMargin = 0 'Abstand auf null stellen
    End Sub