Difference between revisions of "Adjust base font size for all formulas of ODT document"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Related Links)
m (Undo revision 186579 added by spammer Goj)
Line 53: Line 53:
 
* [http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=5579&start=0&st=0&sk=t&sd=a&hilit=object+variable+not+set]
 
* [http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=5579&start=0&st=0&sk=t&sd=a&hilit=object+variable+not+set]
 
* [http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=12235]
 
* [http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=12235]
* [http://www.arizona-breast-cancer-specialists.com/brachytherapy/all-about-what-is-brachytherapy.html    Brachytherapy]
+
 
 
[[Category:Macros]]
 
[[Category:Macros]]

Revision as of 09:42, 12 October 2010

The task can be easily done by this macros:

REM  *****  BASIC  *****
 
Sub Formulator
Dim Doc As Object
Dim objects As Object
Dim obj As Object
Dim embedded As Object
Dim formula As String
Dim newFontSize As Integer
 
newFontSize = InputBox("New formula font size:", "BaseFontHeight", 14)
 
' Create document object
doc = ThisComponent
rem doc = StarDesktop.CurrentComponent
 
' get objects
objects = Doc.getEmbeddedObjects()
 
' now iterate objects
MsgBox("There are " + objects.count + " objects found.")
For i = 0 to objects.count - 1
 
	rem embedded = objects(i).getEmbeddedObject() 'this line produces 'Object variable not set' when i becomes 20
	embedded = objects(i).embeddedObject 'but this code works!
 
	rem MsgBox("i=" + i + " name=" + objects(i).name + " " + embedded.Formula)
 
	If embedded.supportsService("com.sun.star.formula.FormulaProperties") Then
		embedded.BaseFontHeight = newFontSize
		' some tricks to force OO.o redraw formulas
		formula = embedded.Formula
		embedded.Formula = ""
		embedded.Formula = formula
	End If
 
Next i
 
doc.reformat()
 
MsgBox("Done!")
 
End Sub

Related Links

This is a modified version of the code from here [1] (it seems that original version doesn't work in Ooo 3.1).

Other urls about this subject:

Personal tools