Hello!
I'd like to have a random number (between, say 1 - 50 ) in the footer of a write document. Each page should generate it's own number. Ideally, this should refresh when the document is loaded, like =rand() in a spreadsheet. I looked around and have been unable to find a solution, but it was suggested I might be able to do this with a macro. I'm afraid I've never done any scripting for open office and I don't really know where to start. Any help greatly appreciated.
Thanks!
I'd a like a random number in my footer of a write document
I'd a like a random number in my footer of a write document
OOo 3.0.X on Ms Windows XP + Amiga OS
Re: I'd a like a random number in my footer of a write document
Hi Steve
I haven't found a built in rand() function.
If it doesn't need to be a true random number, you won't need to use macros.
You can insert a user field and specify a formula for it. If you'd take something like 1+49*sin(<seconds of current time>), you should get something that looks pretty much like random.
I haven't found a built in rand() function.
If it doesn't need to be a true random number, you won't need to use macros.
You can insert a user field and specify a formula for it. If you'd take something like 1+49*sin(<seconds of current time>), you should get something that looks pretty much like random.
OOo 3.0.X on Ms Windows W2k
Re: I'd a like a random number in my footer of a write document
Hi,
Thanks for your reply.
Forgive me for not being able to find this in the documentation (I find the documentation quite hard to use.) but what do I use to get the seconds for the formula? I tried ss {ss} now() time()...
Also, won't this produce the same random number on each page? If so, I'm afraid this isn't what I am looking for.
Thanks for your reply.
Forgive me for not being able to find this in the documentation (I find the documentation quite hard to use.) but what do I use to get the seconds for the formula? I tried ss {ss} now() time()...
Also, won't this produce the same random number on each page? If so, I'm afraid this isn't what I am looking for.
OOo 3.0.X on Ms Windows XP + Amiga OS
Re: I'd a like a random number in my footer of a write document
Hi Steve
Perhaps I understand now better what you're looking for - open 1 document with 1 to 50 pages and shuffle the numbers in the footers on opening the document?
If so, you'll probably indeed need macros. And yes, the documentation is hard to find.
You'll need to download the BASIC Programmer's Guide from the Documentation Project Wiki (look in the box titled "Developers/SysAdmin Guides") as PDF/ODT and...
the Basic chapter of the Developer's Guide ("Download as PDF or ODT" is the first line there).
These guides are rather different and complement each other.
Perhaps I understand now better what you're looking for - open 1 document with 1 to 50 pages and shuffle the numbers in the footers on opening the document?
If so, you'll probably indeed need macros. And yes, the documentation is hard to find.
You'll need to download the BASIC Programmer's Guide from the Documentation Project Wiki (look in the box titled "Developers/SysAdmin Guides") as PDF/ODT and...
the Basic chapter of the Developer's Guide ("Download as PDF or ODT" is the first line there).
These guides are rather different and complement each other.
OOo 3.0.X on Ms Windows W2k
Re: I'd a like a random number in my footer of a write document
I can give you a little code to get started. The following puts a random number as the footer of every page of a document. I didn't see a way to edit the footer of an individual page. I don't do writer macros for myself, so I'm largely ignorant of the objects involved. I copied from Andrew Pitionyak's English Macro Document at his website to do this.
Code: Select all
oDoc = ThisComponent
sName = oDoc.getCurrentController().getViewCursor().PageStyleName
oStyle = oDoc.StyleFamilies.getByName("PageStyles").getByName(sName)
oStyle.FooterIsOn = True
oStyle.FooterText.String = STR(Int(1+ RND * 49))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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.