I found a strange thing by trying to protect a text in calc.
First step to final goal is to mark this text, but why it is not possible to change the back color from the beginning?
(If I start from beginning, there is no back color at all)
Code: Select all
Sub Get_FilePath
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim oDoc as Object
dim oSheet as Object
dim oCell as Object
Dim oCursor As Object
Dim oSelection As Object
dim sDocumentPath as String
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
sDocumentPath = environ("HOMEDRIVE") + environ("HOMEPATH")
oDoc = thisComponent
oSheet = oDoc.currentcontroller.activesheet
rem ----------------------------------------------------------------------
oCell = oSheet.getCellrangeByName("B20")
oCell.string=" Protected Text"
oCursor= oCell.CreateTextCursor()
oCursor.gotoStart(False)
'with start from beginning or goRight=0 no BackColor is visible
oCursor.goRight(1,False)
oCursor.gotoEnd(True)
REM - it has worked once to get BackColor to the beginning,
'but it was a small white gap after first charakter:
'oCursor.gotoStart(True)
'oCursor.CharWeight = 150 'Fett
'oCursor.CharPosture = 2 'Kursiv
oCursor.CharBackColor = RGB(192, 192, 192)
oCursor.CharBackTransparent = 0
xray oCursor
End Sub
-VBandOpenOffice-