2009/6/25 Zhengquan Zhang <[email protected]>:
> On Thu, Jun 25, 2009 at 06:35:14PM +0200, Johnny Rosenberg wrote:
>> 2009/6/25 Zhengquan Zhang <[email protected]>:
>> > Hello, openoffice list,
>> >
>> > I need to frequently add background color for cells and I was wondering
>> > if who has keyboard shortcuts for doing this job. I also need keyboard
>> > shortcuts for getting text bold, italics, etc.
>>
>> What's wrong witn Ctrl+b, ctrl+i and ctrl+u?
>
> great shortcuts and I never know them.
>
>>
>> If you want to add a certain background colour, why not just add it
>> manually in one cell and then do Shift+Ctrl+y (repeat last command)
>> for the rest of the cells?
>
> hmm, there would be other actions between adding background color so
> this would not work.
>
>>
>> Of course you could create a macro that applies something, like a
>> certain background colour, to a cell range and then assign a key
>> combination to it.
>
> I will take a search of macros.

I just made one for you, that gives the currently selected cell range
a specific colour, in this case ff6464 (hexadecimal HTML notation):

REM  *****  BASIC  *****

Option Explicit

Sub BgColour01
        setBackgroundColour("ff6464")
End Sub

Sub setBackgroundColour(Colour As String)
        Dim Sheet As Object, CellRange As Object, Selection As Object
        Dim SheetNo As Integer, SCol As Integer, SRow As Integer
        Dim ECol As Integer, ERow As Integer
        
        Selection=ThisComponent.CurrentSelection.getRangeAddress()
        SheetNo=Selection.Sheet
        SCol=Selection.StartColumn
        SRow=Selection.StartRow
        ECol=Selection.EndColumn
        ERow=Selection.EndRow
        
        Sheet=ThisComponent.getSheets().getByIndex(SheetNo)
        CellRange=Sheet.getCellRangeByPosition(SCol,SRow,ECol,ERow)

        CellRange.setPropertyValue("CellBackColor",CLng("&H" & Colour))
End Sub

Also note that I mix British and US English in this macro…
I didn't add any comments to that code, so feel free to ask.

The macro will work for cell ranges as well as for individual cells.

Johnny Rosenberg


>
>>
>>  It would be great if
>> > who can point to a list of openoffice shortcuts for this kind of tasks.
>>
>> There is a list built in, kind of:
>> Tools → Customize… → Keyboard → Just scroll the list to view all the
>> shortcuts. Or change them, add stuff or remove stuff. The choice is
>> yours… :)
>
> Great, Thanks a lot,
>
>>
>> Johnny Rosenberg
>>
>> >
>> > Thanks and have a nice day/evening,
>> >
>> > --
>> > Zhengquan
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>
> --
> Zhengquan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to