[Solved] Modify cell address

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
kebab4you
Posts: 7
Joined: Thu Jul 09, 2015 4:40 pm

[Solved] Modify cell address

Post by kebab4you »

Seems like a simple thing but couldn't find any documentation how to access a cell's col and row number. I got a cell that I've given a string to and now I would like to move one column over and input a specific formula.

Basically what I want to do is:

Code: Select all

oCell = ThisComponent.getCellByName("A4")
oCell.String = "Value"
oCell.Column = oCell.Coumn+1
oCell.Formula = "=0"
Last edited by kebab4you on Wed Aug 05, 2015 7:54 pm, edited 1 time in total.
OpenOffice 4.1.1
Windows 7
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Modify cell address

Post by FJCC »

This macro acts on the currently active sheet.

Code: Select all

oSheet = ThisComponent.CurrentController.ActiveSheet
oCellA4 =oSheet.getCellRangeByName("A4")
oCellA4.String = "Value"
CellAddr = oCellA4.CellAddress
oNeighbor = oSheet.getCellByPosition(CellAddr.Column + 1, CellAddr.Row)
oNeighbor.Formula = "=0"
OpenOffice 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.
kebab4you
Posts: 7
Joined: Thu Jul 09, 2015 4:40 pm

Re: Modify cell address

Post by kebab4you »

FJCC wrote:This macro acts on the currently active sheet.

Code: Select all

oSheet = ThisComponent.CurrentController.ActiveSheet
oCellA4 =oSheet.getCellRangeByName("A4")
oCellA4.String = "Value"
CellAddr = oCellA4.CellAddress
oNeighbor = oSheet.getCellByPosition(CellAddr.Column + 1, CellAddr.Row)
oNeighbor.Formula = "=0"
Perfect, thanks a lot!
OpenOffice 4.1.1
Windows 7
Post Reply