[Solved] Properties - average number of words per page
-
- Posts: 12
- Joined: Thu Dec 27, 2007 6:17 pm
[Solved] Properties - average number of words per page
Hi, wondering if someone has an easy answer for my problem. I need to know the average number of words per page. How do I set it up and how do I get it to show in the properties? I need to know this for the novel I am writing.
Last edited by Villeroy on Fri Aug 06, 2010 8:59 pm, edited 1 time in total.
- Hagar Delest
- Moderator
- Posts: 32657
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Properties - average number of words per page
The first idea I can think of is to use a table with 3 cells: put fields inside (Insert>Fields>Other>Document tab) the first 2 cells for the number of words and the number of page. In the 3rd cell, hit F2 to display the formula toolbar and then click the cell with the number of words, then then "/" operator and then the second cell with the number of pages. Hit return and there it is.
Please add '[Solved]' at beginning of your first post title (edit button) if your issue has been fixed.
Please add '[Solved]' at beginning of your first post title (edit button) if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: Properties - average number of words per page
Your number of words is shown in Properties (Caveat: OOo miscounts because of quotes and apostrophes, so shows more words than a hand-count - at least, it used to do so). Your number of pages is shown on the left of the status bar. Divide one by the other and you will get a ballpark figure. This depends on OOo's word count, and page size (smaller pages = fewer words). Normally a publisher cares only about total word-count. Typically in non-technical English text divide number of characters in a file by 5.5 and you have a word-count (just verified it on War and Peace).
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Properties - average number of words per page
Here is a solution with macro.
The code is based on example code of:
http://user.services.openoffice.org/en/ ... 20&t=17358
You can copy the code into OOo Standard library, and you can associate the sub "PrintWordAverage" to a new Menu item (customize Toolbar).
The code works exactly after Save of document.
The code is based on example code of:
http://user.services.openoffice.org/en/ ... 20&t=17358
You can copy the code into OOo Standard library, and you can associate the sub "PrintWordAverage" to a new Menu item (customize Toolbar).
The code works exactly after Save of document.
Code: Select all
REM ***** BASIC *****
Option Explicit
sub PrintWordAverage
dim WordAverage as double
WordAverage = GetWordCount()/GetPageCount()
MsgBox(WordAverage, 64, "The average number of words per page:")
end sub
Function getPageCount as integer
getPageCount = ThisComponent.CurrentController.PageCount
End Function
Function getWordCount as integer
dim oDoc as object
dim oProps as object
dim aStats as object
dim i as integer
dim x as object
oDoc = ThisComponent
oProps = oDoc.getDocumentProperties()
REM or pseudo-property: oProps = oDoc.DocumentProperties
aStats = oProps.DocumentStatistics ' true property
REM oDoc.getDocumentStatistics() is not a valid method call
REM Loop through the array of c.s.s.beans.NamedValue
for i = uBound(aStats) to 0 step -1
x = aStats(i)
if x.Name = "WordCount" then exit for
next
getPageCount = 0
if i > -1 then getWordCount = x.Value
'getWordCount = ThisComponent.CurrentController.WordCount
End Function
Last edited by Zizi64 on Fri Aug 06, 2010 6:46 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
- Hagar Delest
- Moderator
- Posts: 32657
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Properties - average number of words per page
You just have now to find a snippet about creating the custom information for the properties field.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: Properties - average number of words per page
Here you are. The code to add user defined property "Words per Page" does not work. The code requires that you have that custom property already set in your template.Hagar de l'Est wrote:You just have now to find a snippet about creating the custom information for the properties field.
- Attachments
-
- wpp.odt
- Simple custom field with update by button
- (10.28 KiB) Downloaded 167 times
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Properties - average number of words per page
It is for me?Here you are. The code to add user defined property "Words per Page" does not work. The code requires that you have that custom property already set in your template.Hagar de l'Est wrote:You just have now to find a snippet about creating the custom information for the properties field.
Villeroy, your code:
works for me fine. I have completed it a few lines...The code is based on example code of:
viewtopic.php?f=20&t=17358
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Properties - average number of words per page
I added the information about words per page to the custom properties (menu:File>Properties...), so the figure can be displayed anywhere in the document like a page count field or time stamp (menu:Insert>Fields>Other... tab:DocInfo,type:Custom]. WHat I did not get right, is how to add such a custom property to the ducument. I had to comment out this line:
Code: Select all
if not psi.hasPropertyByName(cUDP) then udp.addProperty(cUDP,0,WordAverage)
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 12
- Joined: Thu Dec 27, 2007 6:17 pm
Re: Properties - average number of words per page
Wow what a response thanks all. I am very grateful, thank you
- Hagar Delest
- Moderator
- Posts: 32657
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Properties - average number of words per page
Zizi64 wrote:It is for me?
No, sorry, I should have made it clearer, it was for the OP!
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10