Jonathan Kaye wrote:
Hi again,
I'm now trying to get my head around how objects work in macros. I'm trying
to write a subroutine that will take the contents of a cell and embolden
the text up to a fullstop and leave the rest of the string unchanged.
Borrowing shamelessly from Andrew's excellent manual I've managed to get
this far:
Sub SetBold
Dim oDoc As Object, oSheet As Object, oCell As Object
Dim myselection as object
Dim Position as Integer
oDoc=ThisComponent
oSheet=oDoc.Sheets.getByName("Sheet1")
oCell=oSheet.getCellByposition(0,0) 'A1
Position = InStr(oCell.getString(), ".") 'This works
Print Mid(oCell.getString(), 1, Position - 1) 'This works too
myselection = oCell.Mid(oCell.getString(), 1, Position - 1) 'This doesn't
End Sub
The line beginning "myselection = ..." is obviously wrong. My problem is I
don't know how to relate "myselection" to oCell in such a way that I can
assign properties like fontweight etc. to it and then concatenate the
result with the rest of the string. myselection should be a substring of
oCell from position 1 up to the fullstop but I don't understand how to
create new objects that are substring of existing objects. Can someone
enlighten me?
Have a look at the different macro's you can find under
OpenOffice.orgMacros >> Gimmicks >> Gettexts
this must explain how to handle formating etc..
Hope it helps
Fernand
Thanks in advance for the help.
Jonathan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]