| View previous topic :: View next topic |
| Author |
Message |
Luc Guest
|
Posted: Wed Oct 15, 2003 1:44 am Post subject: How the fill holes in column? |
|
|
In a sheet, I have one column with names but as there are multiple rows for that name, the name is not repeated but i need it on all rows for further .
So I try to write a macro to do that
Sub Main
Dim oDocument As Object, oSheet As Object, oCell As Object
Dim celule as string
Dim cur_nom as string
oDocument=ThisComponent
oSheet=oDocument.Sheets(0)
'B13 is
row = 12
col = 1
'------
maxrow = 20
do
oCell=oSheet.getCellByPosition(col,row)
celule = oCell.String
if len(celule) <> 0 then
'not empty
cur_nom = celule
else
'empty
oCell.setstring(cur_nom)
endif
row = row + 1
loop until row > maxrow
End Sub
That doesn't work because len(celule) always return the length of the first name even in the current cell is empty.
Please please help me. |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
Posted: Wed Oct 15, 2003 9:06 am Post subject: |
|
|
I have found this in 817-1826-10.pdf (SUN document api.openoffice.org) :
To check if the contents of a cell contains a number or a string, use the Type property:
| Code: |
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Doc = StarDesktop.CurrentComponent
Sheet = Doc.Sheets(0)
Cell = Sheet.getCellByPosition(1,1)
Cell.Value = 1000
Select Case Cell.Type
Case com.sun.star.table.CellContentType.EMPTY MsgBox "Content: Empty"
Case com.sun.star.table.CellContentType.VALUE MsgBox "Content: Value"
Case com.sun.star.table.CellContentType.TEXT MsgBox "Content: Text"
Case com.sun.star.table.CellContentType.FORMULA MsgBox "Content: Formula"
End Select] |
Does this answer to your question ? _________________ Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide |
|
| Back to top |
|
 |
Luc Guest
|
Posted: Thu Oct 16, 2003 6:16 am Post subject: |
|
|
It could
Finally i found a work around maybe not too academic
I just do
if len(trim(celule)...
Thanks anyway |
|
| Back to top |
|
 |
|