OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How the fill holes in column?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Luc
Guest





PostPosted: Wed Oct 15, 2003 1:44 am    Post subject: How the fill holes in column? Reply with quote

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
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Oct 15, 2003 9:06 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Luc
Guest





PostPosted: Thu Oct 16, 2003 6:16 am    Post subject: Reply with quote

It could
Finally i found a work around maybe not too academic
I just do

if len(trim(celule)...

Thanks anyway
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group