[Solved] Properties - average number of words per page

Discuss the word processor

[Solved] Properties - average number of words per page

Postby tony_photoplus » Fri Aug 06, 2010 11:08 am

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.
tony_photoplus
 
Posts: 10
Joined: Thu Dec 27, 2007 6:17 pm

Re: Properties - average number of words per page

Postby Hagar Delest » Fri Aug 06, 2010 12:45 pm

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.
AOO 4.0.1 on Windows 7 and Xubuntu 14.04 (Trusty Tahr)
User avatar
Hagar Delest
Moderator
 
Posts: 25113
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Properties - average number of words per page

Postby RoryOF » Fri Aug 06, 2010 1:32 pm

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.0.1 on Xubuntu 14.04 and Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 14377
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Properties - average number of words per page

Postby Zizi64 » Fri Aug 06, 2010 5:32 pm

Here is a solution with macro.
The code is based on example code of:
viewtopic.php?f=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   Expand viewCollapse view
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; AOO4.0.1, LO3.6.4, LO4.2.2 on WinXPprof.SP3
Zizi64
Volunteer
 
Posts: 1784
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Properties - average number of words per page

Postby Hagar Delest » Fri Aug 06, 2010 6:19 pm

You just have now to find a snippet about creating the custom information for the properties field.
AOO 4.0.1 on Windows 7 and Xubuntu 14.04 (Trusty Tahr)
User avatar
Hagar Delest
Moderator
 
Posts: 25113
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Properties - average number of words per page

Postby Villeroy » Fri Aug 06, 2010 7:17 pm

Hagar de l'Est wrote:You just have now to find a snippet about creating the custom information for the properties field.

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.
Attachments
wpp.odt
Simple custom field with update by button
(10.28 KiB) Downloaded 58 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 12.04, Apache OpenOffice 4.x
User avatar
Villeroy
Volunteer
 
Posts: 17319
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Properties - average number of words per page

Postby Zizi64 » Fri Aug 06, 2010 7:46 pm

Hagar de l'Est wrote:You just have now to find a snippet about creating the custom information for the properties field.

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.

It is for me?

Villeroy, your code:
The code is based on example code of:
viewtopic.php?f=20&t=17358

works for me fine. I have completed it a few lines...
Average.odt
(10.37 KiB) Downloaded 61 times

Average.png
Tibor Kovacs, Hungary; AOO4.0.1, LO3.6.4, LO4.2.2 on WinXPprof.SP3
Zizi64
Volunteer
 
Posts: 1784
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Properties - average number of words per page

Postby Villeroy » Fri Aug 06, 2010 8:06 pm

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   Expand viewCollapse view
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 12.04, Apache OpenOffice 4.x
User avatar
Villeroy
Volunteer
 
Posts: 17319
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Properties - average number of words per page

Postby tony_photoplus » Fri Aug 06, 2010 8:12 pm

Wow what a response thanks all. I am very grateful, thank you
tony_photoplus
 
Posts: 10
Joined: Thu Dec 27, 2007 6:17 pm

Re: Properties - average number of words per page

Postby Hagar Delest » Fri Aug 06, 2010 9:08 pm

Zizi64 wrote:It is for me?

:oops:
No, sorry, I should have made it clearer, it was for the OP!
AOO 4.0.1 on Windows 7 and Xubuntu 14.04 (Trusty Tahr)
User avatar
Hagar Delest
Moderator
 
Posts: 25113
Joined: Sun Oct 07, 2007 9:07 pm
Location: France


Return to Writer

Who is online

Users browsing this forum: jamesd1, twoolds and 29 guests