PDA

View Full Version : Solved: Field displaying "Number of References"



Adamski
10-07-2009, 07:41 AM
Hi all,

I have a report which has a list of all the references used in the report in a numbered "Reference Item" style. At the back of the report is a documentation page containing a number of details (auther, title, date, customer, protective marking etc) to which I wish to add "Number of References". I think this is a job for a field since it will just be a count of the "Reference Item" style but I can't figure out how to do it.

Is it possible to do, and if so how?

Any help most welcome and greatly appreciated.

macropod
10-07-2009, 06:28 PM
Hi Adamski,

You could probably do what you're after with a macro using Word's 'Find' function and a counter, then populating a bookmarked range with the counter value. Do note, though, that:
. Your referencing would have to be consistent and unambiguous
. The counts would not be dynamic.

fumei
10-08-2009, 10:15 AM
I concur. Your referencing MUST be consistent and unambiguous.

I also am a little confused.

"I wish to add "Number of References". I think this is a job for a field since it will just be a count of the "Reference Item" style"

OK, as macropod points out, this could be fairly easy (although it would not automatically update), but it is your mentioning of various items:

"At the back of the report is a documentation page containing a number of details (auther, title, date, customer, protective marking etc) to which I wish to add "Number of References". "

that confuses me. You can easily count how many paragraphs are using the "Reference Item" style.Dim counter As Long
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
If oPara.Range.Style = "Reference Item" Then
counter = counter + 1
End If
Next
Voila. The variable "counter" is the count of the number of paragraphs that are using the "Reference Item" style. That value - counter - can be, as macropod suggests, be put into a bookmark anywhere you like.

But it is the counter of ALL paragraphs. There is no indication of content (what may be in the paragraph). What is - if any - the connection to "auther, title, date, customer, protective marking etc."? Because if you are trying to determine some sort of linkage, then that is a much greater problem.

Adamski
10-19-2009, 04:39 AM
Thanks for the responses.

I was really thinking there would be a way to duplicate the number of the numbering of the last use of the style and avoid needing to use VBA.

As it is currently, my fields on the documentation page simply display CustomDocProperties. When I generate a report from a database, these CustomDocProperties are populated, thereby filling in the field. I do this for the "Number of References" fiels too, but that means the number displayed is just what i exported from the database and not actually related to the sue of the style.

macropod
10-19-2009, 02:36 PM
Hi Adamski,

If you format the paragraphs containing the details for which you want the count in a particular numbered Style, you may be able to use a STYLEREF field for what you're after. The STYLEREF field can return the number of the last such paragraph.

Adamski
11-12-2009, 04:04 AM
It's been a while as I have been on leave but I figured I'd share my solution.

I simply used an outline numbered list with a "Listnum field list name" of ReferenceItem.
Level one "Link level to style" is set to my "Reference Item" style.
For level two I set the "Number format" to just display the level 1 number.

I then use the field:
{ LISTNUM ReferenceItem \l 2 }
to display the number.

Thanks for all your suggestions

Adamski
12-04-2009, 03:25 AM
Unfortunatly, the solution in my previous post doesn't work when there are no uses on the "Reference Item" style - It returns 1, not 0.
So... I have been trying to use a LISTNUM field with an if or calculation:
{ if { LISTNUM ReferenceItem \l 1 } ="1" "0" "not 0" }
{ ={ LISTNUM ReferenceItem \l 1 }-1 }

but I have been unable to get any formulas to work when they contain a LISTNUM field.

Can LISTNUM fields be used in FORMULA fields?
If so please provide an example

Or how do I link a style to a SEQ so I can use that instead?

Thankyou

ps. Can I UnSolve this thread somehow?