Ask Your Question

daniel b.'s profile - activity

2019-07-28 13:35:02 +0200 received badge  Taxonomist
2015-01-23 22:03:04 +0200 received badge  Famous Question (source)
2015-01-23 22:03:04 +0200 received badge  Notable Question (source)
2014-10-20 10:16:50 +0200 received badge  Popular Question (source)
2014-10-18 07:22:43 +0200 answered a question Macro to change colour of some words in a string in a cell in Calc ?

Found a solution. Here it is, in case anyone hits the same wall as I had :)

Sub Main

Dim oDoc as Object, oSheet as Object, oCell as Object
Dim oTextCursor as Object
    oDoc=ThisComponent
    oSheet=oDoc.getSheets().getByindex(0)
    oCell=oSheet.getCellByPosition(0,1)
    oCell.String="The Moon is in synchronous rotation with Earth, always showing the same face with its near side marked by dark volcanic maria that fill between the bright ancient crustal highlands and the prominent impact craters. It is the second-brightest object in the sky, after the Sun (measured by illuminance on the surface of the Earth)"
    with oCell
        .CharFontName = "Arial"
        '.CharPosture = com.sun.star.awt.FontSlant.ITALIC
        .CharHeight=12      
    end with

str_length = len (oCell.String)

str_searched = "ea"
str_searched_length = len (str_searched)

oTextCursor = oCell.createTextCursor()

for i = 1 to str_length
    found = instr (i, oCell.String, str_searched)
    if found > 0 then
            With oTextCursor
                .gotoStart( False )
                .goRight(found-1 , False )  
                .goRight(str_searched_length, True )
                .setPropertyValue("CharColor",0099000)  
                .gotoEnd( False )
            End with
        i = i + found+str_searched_length
    endif
next i

End Sub

2014-10-17 11:51:07 +0200 answered a question Macro to change colour of some words in a string in a cell in Calc ?

Not a precise answer but it works something similar to what I need. Should be able to adapt

oCell = sheet_sursa.GetCellbyPosition( I, j) oTextCursor = oCell.createTextCursor() With oTextCursor .gotoStart( False ) .goRight(5 , True ) .setPropertyValue( "CharContoured", true ) 
.setPropertyValue( "CharCrossedOut", true )
.setPropertyValue( "CharStrikeout", 2 )
.setPropertyValue( "CharEmphasis",3)
.setPropertyValue( "CharWordMode",false)
.setPropertyValue( "CharUnderlineColor", 2918503 )
.setPropertyValue( "CharUnderline",1)
.setPropertyValue( "CharRelief",5)
.setPropertyValue( "CharShadowed",true)
.gotoEnd( False ) End with

Found it on http://openoffice3.web.fc2.com/OOoBas...

2014-10-17 09:09:56 +0200 received badge  Editor (source)
2014-10-17 09:03:30 +0200 commented question Macro to change colour of some words in a string in a cell in Calc ?

Of course, using a macro... :)

2014-10-17 08:59:33 +0200 asked a question Macro to change colour of some words in a string in a cell in Calc ?

The results of a word search in a range in a LibreOffice Calc sheet are displayed on A1...A100 cells. Each cell may contain a paragraph of text within which there is the search result (somewhere). It's sometimes hard to quickly see where the result is. How can one change the colour and weight only for the searched word not the entire cell?

Something like this: .....[2014_10_15 order delivered ] [2014_10_13 received DK instruments] [2014_10_05 : DK order placed, payment.....]

Thanks.

2013-12-10 12:48:00 +0200 received badge  Famous Question (source)
2013-11-05 00:27:17 +0200 received badge  Notable Question (source)
2013-11-01 15:59:13 +0200 received badge  Popular Question (source)
2013-11-01 04:01:26 +0200 asked a question Will my simple macros work on linux?

I've created 8 rather simple macros for calc in libreffice in windows. Nothing fancy, just search on a sheet and write on anothet sheet, in the same file, text formatting. Still, they are essential to my work. Would they work on linux (mint) in libreoffice? Have you had problems migrating macros from libreoffice under windows to libre office under linux? What linux version? Windows Office Pc broke, money is tight. I would rather spend on a reasonably new hardware than on a very old hardware with windows , even refurbished

Thank you, all