# How do i write a macro that will increase / decrease font size within a cell in Calc?

How do i write a macro that will increase / decrease font size within a cell in Calc?

EDIT ebot: yelling off

edit retag close merge delete

Could you please explain what Get SUM result depending on filter result in calc got to do with (yelling) HOW DO i WRITE A MACRO THAT WILL INCREASE / DECREASE FONT SIZE WITHIN A CELL IN CALC?

( 2019-12-26 20:06:10 +0100 )edit

changed summary

( 2019-12-27 19:54:10 +0100 )edit

The "within" is doubtable. The font size (.CharHeight) is generally set for a CellStyle or by direct formatting for a cell or cell range. To set it inside (within) a cell for textportions requires to describe these portions.
I read "for" in place of "within".

( 2019-12-27 22:48:07 +0100 )edit

Sort by » oldest newest most voted

Concerning cell attributes: The relevant question is, how to pass the SheetCell (or SheetCellRange) on which to operate, to the "macro". This done, it's easy: SCR.CharHeight = yourNewValue (in points).
(SCR being the SheetCellRange object, probably a single cell.)

For those wanting to do it for the CurrentSelection which may be a multirange selection I want to add that the selection object ScCellRangesObj (Regard the plural!) also supports the service "com.sun.star.style.CharacterProperties" and therefore gives setting acces to .CharHeight "and everything". You don't need to roam the single ranges.
===End Edit===

Concerning the sum applied to filtered ranges: =SUBTOTAL(109;yourRangeReference) (see help).
Not wrong, but no longer subsumable under the edited question.

more

Thanks for your assistance, my apologies for shouting and posting in the wrong place! How do I get the character height from the active cell? Thanks

more

The "active cell" seems to be something often used in Excel-VBA.
In cases where there is selected exactly one cell (whether highlighted or not) get something alike as the documents current selection (ThisComponent.CurrentSelection). In cases where a range is selected (or multiple ranges) exactly one cell has the keyboard focus (or is prepared to get it if a non-cell object gives it back). To get this cell requires slightly obscure means - or trusting in Option VBAsupport 1 which is a bit more than just experimental. Under this option ActiveCell.CellRange.CharHeight should return what you want.