I generally send only to the list. This is what you missed if it did not
make it.
You are doing nothing wrong.... The macro recorder fails to record
certain actions and should be reworked from the start, but, that is not
likely to happen (sadly). If you want to set the first character to bold
regardless of what you have selected, you could run something like this
(your welcome):
Sub FirstCharBold
Dim oOldSelection 'The original selection of cell ranges
Dim oDoc
Dim oCells
Dim oCell
Dim oEnum
Dim iRows As Integer
Dim iCols As Integer
Dim iRow As Integer
Dim iCol As Integer
oDoc = ThisComponent
REM store the current selection
oOldSelection = oDoc.CurrentSelection
If HasUnoInterfaces(oOldSelection, "com.sun.star.text.XText") Then
'Inspect oOldSelection
BoldFirstChar(oOldSelection.getText())
ElseIf HasUnoInterfaces(oOldSelection,
"com.sun.star.sheet.XSheetCellRanges") Then
oCells = oOldSelection.getCells()
oEnum = oCells.createEnumeration()
Do While oEnum.hasMoreElements()
oCell = oEnum.nextElement()
BoldFirstChar(oCell.getText())
Loop
ElseIf HasUnoInterfaces(oOldSelection,
"com.sun.star.sheet.XSheetCellRange") Then
iCols = oOldSelection.getColumns().getCount() - 1
iRows = oOldSelection.getRows().getCount() - 1
For iRow = 0 To iRows
For iCol = 0 To iCols
oCell = oOldSelection.getCellByPosition(iCol, iRow)
BoldFirstChar(oCell.getText())
Next
Next
Else
Print "Help, what is selected"
End If
End Sub
Sub BoldFirstChar(oText)
Dim oCurs
oCurs = oText.createTextCursor()
' Goto start of text but do not select anything.
oCurs.gotoStart(False)
If oCurs.goRight(1, True) Then
oCurs.CharWeight = com.sun.star.awt.FontWeight.BOLD
End If
End Sub
On 07/17/2014 01:41 AM, [email protected] wrote:
david_lynch <[email protected]> posted to
[email protected] at 0:23 on Sun, 13 Jul 2014 about Calc macro - selection
by keyboard not recorded:
On 13/07/2014 01:46, Andrew Douglas Pitonyak wrote:
On 07/12/2014 04:41 PM, david_lynch wrote:
Although reasonably experienced using calc, I haven't used macros much.
<snip>
What am I doing wrong please?
David Lynch
4.2.4.2 on Windows 8
You are doing nothing wrong.... The macro recorder fails to record
certain actions and should be reworked from the start, but, that is
not likely to happen (sadly). If you want to set the first character
to bold regardless of what you have selected, you could run something
like this (your welcome):
<snip>
What did Andrew suggest? As far as I can tell, the snipped suggestion never
made it to this list.
[RANT]
This is a perfect example of why it is stupid to not post ordinary replies to
this list!
[/RANT]
Many thanks Andrew. I had simplified what I wanted: your code will, I
think, enable me to complete the task.
David Lynch
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
To unsubscribe e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted