Page 1 of 1
[Solved] VB : Different style in a cell
Posted: Wed Sep 10, 2014 5:32 pm
by OPENMSA
Hello,
I am trying to set a cell with 3 different styles (fonts, size) in macro VB.
Is it possible?
How?
Re: VB : Different style in a cell
Posted: Wed Sep 10, 2014 6:22 pm
by Villeroy
You just do not know what a style is.
https://wiki.openoffice.org/wiki/Docume ... _Templates
Code: Select all
objCell.CellStyle = "My_Sophisticated_Cell_Style_With_Dozends_of_Attributes"
Re: VB : Different style in a cell
Posted: Thu Sep 11, 2014 10:20 am
by OPENMSA
It seems style apply on the whole cell. Let's forget about style :
I am trying to set a cell with 3 differents fonts & size in macro VB.
Is it possible?
How?
Re: VB : Different style in a cell
Posted: Thu Sep 11, 2014 12:03 pm
by karolus
Hallo
OPENMSA wrote:...in macro VB.
Is it possible?
How?
Yes, of course -- but what the hell is VB
Code: Select all
def word_formatter():
doc = XSCRIPTCONTEXT.getDocument()
sel = doc.CurrentSelection #works for one single selected Cell !!
cursor = sel.createTextCursor()
sentence = 'just three words'.split()
sizes = (12,20,15)
fonts = ('Carlito', 'Linux Biolinum Keyboard', 'Droid Sans')
for word, size, font in zip(sentence, sizes, fonts):
cursor = cursor.End
cursor.CharHeight = size
cursor.CharFontName = font
cursor.Text.insertString(cursor, '%s ' % word, False)
Karolus
Re: VB : Different style in a cell
Posted: Fri Sep 12, 2014 10:03 am
by OPENMSA
Thanks you so much, it works!
Tip : change charWeight, charPosture after a insertControlCharacter (LINE_BREAK...)
Re: VB : Different style in a cell
Posted: Fri Sep 12, 2014 10:51 am
by karolus
OPENMSA wrote:Thanks you so much, it works!
Tip : change charWeight, charPosture after a insertControlCharacter (LINE_BREAK...)
change
to