Hi Jonathan,

I now copied the Code you sent in my OOo-Basic-Editor and it works with
"abc.def" in Cell A1.
It may depend on the Version of OOo and maybe the platform.
Nevertheless the method createTextCursor() is one of XSimpleText and
oCell.createTextCursor()
is just a shortcut for:
oCell.getText.createTextCursor()
So maybe the following Code works for you:

Sub SetBold
  Dim oDoc As Object, oSheet As Object, oCell As Object
  Dim CellCont as string, oTextCursor as Object
  Dim Position as Integer
  oDoc=ThisComponent
  oSheet=oDoc.Sheets.getByName("Sheet1")
  oCell=oSheet.getCellByposition(0,0) 'A1
  Position = InStr(oCell.getString(), ".")

  oTextCursor = oCell.getText.createTextCursor() 'Changed

  oTextCursor.gotoStart(false)
  oTextCursor.goRight(Position - 1, true)
  oTextCursor.setPropertyValue("CharWeight", 150)
End Sub

Jonathan Kaye schrieb:
> Christoph Jopp wrote:
> 
>> Hi Jonathan
>>
>> Jonathan Kaye schrieb:
>>> Hi Christoph,
>>> I tried this:
>>> Sub SetBold
>>>   Dim oDoc As Object, oSheet As Object, oCell As Object
>>>   Dim oTextCursor as Object
>>>   Dim Position as Integer
>>>   oDoc=ThisComponent
>>>   oSheet=oDoc.Sheets.getByName("Sheet1")
>>>   oCell=oSheet.getCellByposition(0,0) 'A1
>>>   Position = InStr(oCell.getValue(), ".")
> Sorry, this was my mistake. I corrected the line to
> ...oCell.getString()
>> In your original post this was:
>> Position = InStr(oCell.getString(), ".")
>> and that works for me.
>> I'm assuming you try to execute this macro with content other than
>> string in cell A1 now???
> No, as I said above. My error. I corrected it and I still get the same
> syntax error. I have a spreadsheet open and with cell A1 containing abc.def
> Just to be very clear. My subroutine now looks like this:
> Sub SetBold
>   Dim oDoc As Object, oSheet As Object, oCell As Object
>   Dim CellCont as string, oTextCursor as Object
>   Dim Position as Integer
>   oDoc=ThisComponent
>   oSheet=oDoc.Sheets.getByName("Sheet1")
>   oCell=oSheet.getCellByposition(0,0) 'A1
>   Position = InStr(oCell.getString(), ".")
>   oTextCursor = oCell.createTextCursor()
>   oTextCursor.gotoStart(false)
>   oTextCursor.goRight(Position - 1, true)
>   oTextCursor.setPropertyValue("CharWeight", 150)
> End Sub
> 
> I get a syntax error at the oTextCursor = oCell.createTextCursor()
> For you the same code functions? If so how exactly do you call the
> subroutine? From the "Run" button in the Basic window?
> Jonathan
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to