[Solved] Old macro for inserting Equation into Writer
Posted: Thu Nov 08, 2012 11:58 am
Hello.
I have some questions about a macro for inserting equation - Math object into a Writer document.
Until recently I was using OOo 3.2.1 and modified macro from Andrew Pitonyak:
But now I installed the Apache OOo 3.4.1 and the macro doesn't work anymore.
It breaks with error message: 'BASIC runtime error. Property or method not found: formula.' at the line
I searched the forum and found some examples:
http://forum.openoffice.org/en/forum/vi ... 30&t=30933
http://forum.openoffice.org/en/forum/vi ... 45&t=45282
http://forum.openoffice.org/en/forum/vi ... 45&t=55285
so I modified my old macro to this:
It works now. But because I don't understand why and how, I have some questions. I would be happy if someone can answer or post some links where I find the answers I'm looking for:
1. Why does the old macro not work anymore.
2. Why do I have to specify the size of the math object - it's tiny not-readable object if I don't do?
3. Why can't I move the new math object in the document as before - in the old version?
4. Is the new modified macro OK now, or should change something more?
I have some questions about a macro for inserting equation - Math object into a Writer document.
Until recently I was using OOo 3.2.1 and modified macro from Andrew Pitonyak:
Code: Select all
Sub InsertEquationAtViewCursor(oDoc, sFormula$)
Dim oVC
Dim oObj
oVC = oDoc.CurrentController.getViewCursor()
oVC.gotoRange(oVC.getEnd(), False)
oObj = oDoc.CreateInstance("com.sun.star.text.TextEmbeddedObject")
oObj.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997"
oObj.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
oVC.Text.insertTextContent(oVC, oObj, False)
oObj.EmbeddedObject.formula = sFormula
End Sub
It breaks with error message: 'BASIC runtime error. Property or method not found: formula.' at the line
Code: Select all
oObj.EmbeddedObject.formula = sFormula
http://forum.openoffice.org/en/forum/vi ... 30&t=30933
http://forum.openoffice.org/en/forum/vi ... 45&t=45282
http://forum.openoffice.org/en/forum/vi ... 45&t=55285
so I modified my old macro to this:
Code: Select all
Sub InsertEquationAtViewCursor(oDoc, sFormula$)
Dim oVC
Dim oObj
oVC = oDoc.CurrentController.getViewCursor()
oVC.gotoRange(oVC.getEnd(), False)
oObj = oDoc.CreateInstance("com.sun.star.text.TextEmbeddedObject")
oObj.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997"
oObj.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
oVC.Text.insertTextContent(oVC, oObj, False)
TempSize = oObj.Size
TempSize.Width = 2000
TempSize.Height = 2000
oObj.Size = TempSize
oObj.Model.formula = sFormula
End Sub
1. Why does the old macro not work anymore.
2. Why do I have to specify the size of the math object - it's tiny not-readable object if I don't do?
3. Why can't I move the new math object in the document as before - in the old version?
4. Is the new modified macro OK now, or should change something more?