I have a spreadsheet with mixed fonts. I want to change them all to one font. I select all the cells and click ‘Format Cells’, and enter the font. Only some of the fonts change.
To change all the fonts I have to outline the text in each cell one-by-one.
Is there any way I can select all the text at one time?
compás4_b_.ods (176.6 KB)
Cells/content not changing font is inline formatted with a specific font, that takes precedence over whole cell formatting. Also note that the Default cell style has Arial as font, which is used if no other attribution is set, but cell styles are overridden by cell hard attribution/formatting (which again is overridden by inline formatting). Maybe someone could come up with a macro that removes the inline font formatting, and probably best also the individual cell font attribution, so changing the style’s font actually could propagate.
We can start with this exercise on nested loops:
Option Explicit
Sub ChangeFontToArial
Dim oRanges, oCell, oPar, oFrag
oRanges=ThisComponent.CurrentSelection.queryContentCells(com.sun.star.sheet.CellFlags.FORMATTED)
oRanges.CharFontName="Arial"
For Each oCell In oRanges.Cells
For Each oPar In oCell.Text
For Each oFrag In oPar
If oFrag.SupportsService("com.sun.star.style.CharacterProperties") Then
If oFrag.CharFontName<>"Arial" Then oFrag.CharFontName="Arial"
End If
Next oFrag
Next oPar
Next oCell
End Sub
Changes the font to Arial in selection cells that have internal formatting.