[Solved] Function to choose any cell by mouse as argument

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
srimal
Posts: 9
Joined: Thu Oct 23, 2008 9:47 am

[Solved] Function to choose any cell by mouse as argument

Post by srimal »

Welcome beginner. What is your question or comment?
Please try to briefly and clearly tell us: What you want, What you tried, and What happened.
-----------------------------------------------------------------------------------------------------------

hi all,
I wrote a function with three argument which has assigned to any cell address and pass the value.but has a problem,
what i want:
1> select my data out put cell [D5]
2> run my function using macro
3> inside function will ask what is the cell u want as argument..then user select a valid cells by mouse
4> out put will in D5

i need to complete 3rd step.

FUNCTION:
Function volume(a, b, c)
volume = a*b*c
End Function
Last edited by srimal on Mon Oct 27, 2008 2:19 pm, edited 2 times in total.
OOo 2.4.X on Ms Windows XP + Red hat 5.0
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function to choose any cell by mouse as argument

Post by Villeroy »

http://www.oooforum.org/forum/viewtopic ... eselection
[Moved away from "Beginners" forum]
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
srimal
Posts: 9
Joined: Thu Oct 23, 2008 9:47 am

Re: Function to choose any cell by mouse as argument

Post by srimal »

I tried above link ....once i select the cell range then suddenly appears a dialog box saying,

>> Title: exit macro:getTargetCellAddress
"Target needs to be on another sheet or behind/below selection"


what was cause for that?

regrds,
srimal
OOo 2.4.X on Ms Windows XP + Red hat 5.0
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function to choose any cell by mouse as argument

Post by Villeroy »

Read the code. It rejects to paste into the copied region.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
srimal
Posts: 9
Joined: Thu Oct 23, 2008 9:47 am

Re: Function to choose any cell by mouse as argument

Post by srimal »

thanx i did it.It copies the cell range as it is.

regrds,
srimal
OOo 2.4.X on Ms Windows XP + Red hat 5.0
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function to choose any cell by mouse as argument [solved]

Post by Villeroy »

The macro copies the tiles of visible ranges to another place. In case of no hidden columns nor rows it copies the selected range.
The genreic part you need for your own stuff is

Code: Select all

Private sRangeSelection$,bRangeSelecting As Boolean
'return a valid com.sun.star.table.CellRangeAddress from a user's range-selection (or Empty)
Function getRangeSelectionAddress(oController,sInitial$,sTitle$,bAutoClose as Boolean) 
[...]
End Function
It returns a com.sun.star.table.CellRangeAddress if the user selected a range. It returns Basic type Empty if the user canceled. You've got to pass the spreadsheet-controller to pick from a default selection as string-address (A1:D4 or empty string), a title for the box and if a single click on the sheet is enough to close the selection box.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply