Ask Your Question
0

How to apply faux bold to cells with particular content

asked 2015-05-27 15:19:33 +0200

jamadagni gravatar image

In relation to my query I experimented a bit with the recent macro recorder and trimmed its bloated output to get the following macro which sure enough applies bold to cells O4 to O45 in all 12 of my sheets.

sub addTithiBold

    document = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dispatcher.executeDispatch(document, ".uno:JumpToFirstTable", "", 0, Array())

    dim selectCells(0) as new com.sun.star.beans.PropertyValue
    dim addBoldAttr(0) as new com.sun.star.beans.PropertyValue

    selectCells(0).Name = "ToPoint"
    selectCells(0).Value = "$O$4:$O$45"
    addBoldAttr(0).Name = "Bold"
    addBoldAttr(0).Value = true

    sheet = 1
    do
        if sheet <> 1 then dispatcher.executeDispatch(document, ".uno:JumpToNextTable", "", 0, Array())

        dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, selectCells())
        dispatcher.executeDispatch(document, ".uno:Bold", "", 0, addBoldAttr())

        sheet = sheet + 1
    loop while sheet < 13

end sub

However I want to apply bold only to cells with particular textual content. Based on the solution given to my query, I was able to add the line:

if oCell.string = "पौर्णमासी" or oCell.string = "अमावास्या" then oCell.charWeight = com.sun.star.awt.FontWeight.BOLD else oCell.charWeight = com.sun.star.awt.FontWeight.NORMAL

but as I have noted in that answer, this is not sufficient to apply faux bold when the font itself does not provide a separate proper bold. However the above dispatch method produced by the macro recorder is able to apply faux bold. Now I'd like to know how to apply the dispatch method by selecting cells with a particular textual content.

Or if there is any other method also to get the required faux bold I'd be happy.

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-05-27 15:45:00 +0200

karolus gravatar image

This Kind of stuff need no makro

select the Range of Interest goto →edit→Search and replace
search (पौर्णमासी)|(अमावास्या) with more Options: [x]regular Expression
→→find all and hit the Toolbar-button for bold...

edit flag offensive delete link more

Comments

Hey thanks for the reply but it would be good to automate this as this is a repeated process I have to do on multiple documents every now and then. If I have a macro, all I have to do is a click on the toolbar.

jamadagni gravatar imagejamadagni ( 2015-05-27 16:24:30 +0200 )edit
1

so record the Actions →Tools→Macros→Record Macro....

karolus gravatar imagekarolus ( 2015-05-27 17:07:46 +0200 )edit

or apply better as →Format→Conditional Format→Condition with the obvious settings

karolus gravatar imagekarolus ( 2015-05-27 17:12:11 +0200 )edit

@karolus: Thanks for your help. While conditional format still doesn't apply faux bold, I recorded the actions and it works fine. Great!

jamadagni gravatar imagejamadagni ( 2015-06-17 13:49:04 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-05-27 15:19:33 +0200

Seen: 278 times

Last updated: May 27 '15