[Solved] Get cell data type via macro?
-
Archdeacon
- Posts: 3
- Joined: Tue Mar 20, 2012 5:30 am
[Solved] Get cell data type via macro?
I am new to Open Office (but do know VB however) so please forgive a dumb question! How do I determine the data type of a cell (VALUE,FORMULA,STRING) when iterating through a loop in a macro. I need to insert FORMULA only when the data is type Value.
Last edited by Hagar Delest on Tue Mar 20, 2012 9:01 am, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 3.1 on Windows 7
Re: Get cell data type via macro?
Here is an example:
The possible values of CellContentType are here: http://www.openoffice.org/api/docs/comm ... tType.html
Code: Select all
oSheet = ThisComponent.Sheets.getByName("Sheet1")
oCell = oSheet.getCellrangeByName("B1")
if oCell.Type = com.sun.star.table.CellContentType.VALUE Then
Print "Yes"
End ifOpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
Archdeacon
- Posts: 3
- Joined: Tue Mar 20, 2012 5:30 am
Re: Get cell data type via macro?
Many thanks indeed for yor prompt reply!
OpenOffice 3.1 on Windows 7
Re: [Solved] Get cell data type via macro?
Hallo
Another example:
Karo
Another example:
Code: Select all
...
oSheet = ThisComponent.Sheets.getByName("Sheet1")
oRange = oSheet.getCellrangeByName("B1:F100")
ValueCells = oRange.querycontentcells(1).createEnumeration
do while ValueCells.hasmoreElements()
cell = ValueCells.nextElement
cell.Formula = "bla"
loop
...Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)