How to insert a field of a random integer in the range 5-20?

Help with installation and general system troubleshooting questions concerning the office suite LibreOffice.

How to insert a field of a random integer in the range 5-20?

Postby samz » Fri Apr 25, 2014 10:43 pm

Hello,
In LibreOffice Writer, how to insert a field of a random integer in the range 5 to 20? This random integer changes every time I open the document.
Thanks and regards.
LibreOffice 4.2.2 on MS Windows Vista Pro 32B
samz
 
Posts: 4
Joined: Tue Jul 21, 2009 3:46 pm

Re: How to insert a field of a random integer in the range 5

Postby RusselB » Fri Apr 25, 2014 11:12 pm

You state LibreOffice Writer in your post, yet your signature indicates you are using OpenOffice.
That aside, I tried to come up with something, unfortunately everything I tried only brought back the result of the formula used, not the actual formula.
I used F2 to access the Formula entry method, then =randbetween(5;20) since that works in OO Calc.
While OO Writer didn't complain about the formula (a good start I thought), it appears to place the first result into the document.
OpenOffice 4.1.6 and LibreOffice 6.0.6.2 on Windows 7 Pro & Ultimate
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
RusselB
Moderator
 
Posts: 5391
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: How to insert a field of a random integer in the range 5

Postby acknak » Sat Apr 26, 2014 12:46 am

If it's a random integer, it's not guaranteed to change every time you open the document ;-)

There's no access to random numbers in Writer--as far as I know.
The closestl I can think of is insert a time field and format it to show only the seconds. That would give you a random integer between zero and 60.

I don't know of any way to get it into the range you want; there's no way that I can see to do any arithmetic with the time field value.

The standard workaround for getting access to spreadsheet features in a text document is to set up the calculation in a separate Calc document and then retrieve the result with a DDE field.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: How to insert a field of a random integer in the range 5

Postby samz » Sat Apr 26, 2014 12:41 pm

Thanks guys.
Sorry for my wrong signature, I just updated it. I use LIBRE OFFICE 4.2.2

Ok, unfortunately I must to use a spreadsheet document to solve my problem :(

I created a Libre Office Calc spreadsheet with a table like this:

Rand2DiG 91
Rand3DiG 725
Rand4DiG 5869
Rand5DiG 61431
Rand6DiG 872247

where the 2nd column formula are defined like this:
=ROUND(RAND()*89)+10
=ROUND(RAND()*899)+100
=ROUND(RAND()*8999)+1000
...
The 1st column is just a "comment", to remind me the purpose of the spreadsheet.

Following your solution of Brian
http://nabble.documentfoundation.org/Ho ... 06448.html

I get the entire table (2 col. x 5 lines) in my Writer document. But I want to insert only the content of one of the second column (the random integer), the value only without any text/cell format from the spreadsheet document. The insert position format* in the Writer document should be use on this inserted value (* text size and format).

So, how to insert only the value of 1 cell?
Thanks and regards.
LibreOffice 4.2.2 on MS Windows Vista Pro 32B
samz
 
Posts: 4
Joined: Tue Jul 21, 2009 3:46 pm


Return to LibreOffice

Who is online

Users browsing this forum: No registered users and 1 guest