GetCellByPosition(r,c).value doesn't read strings?

The value 0 is returned if I try to read a string value in a cell.
I am a newbie, that’s clear!

Any help is welcome…

Dick

Hello,

.value means: “I want a numeric value” and that results in 0, if the cell contains a string. If you want the string you need to use GetCellByPosition(r,c).string and if you want the formula you need GetCellByPosition(r,c).formula. Generally you don’t know the type of content and you need to eval the type before you get the content similar to sType = oCell.Type in the following snippet:

Sub GetCellContent()

   dim oDoc as object
   dim oSheet as object
   dim oCell  as object

   dim sType as string
   dim vCont as variant

   oDoc   = ThisComponent.CurrentController
   oSheet = oDoc.ActiveSheet
   oCell = oSheet.gGetCellByPosition(0,0)

   sType = oCell.Type

   Select Case sType

     case 1
       vCont =  oCell.Value

     case 2
       vCont =  oCell.String

     case 3
       REM vCont =  oCell.FormulaLocal for the localized function name
       vCont =  oCell.Formula
     
     REM This should not occur at all
     Case Else  
       vCont =  oCell.String

   End Select

   Msgbox "Cell type is: " & sType & " Content: " & vCont

End Sub

Hope that clarifies, why you get 0.