View Single Post
  #2   Report Post  
Posted to microsoft.public.word.newusers
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default auto number a word document each time it is opened

The easiest way for you to do that is go to the FileProperties dialog and
then go to the Custom tab and in the Name: field, type DocNumber and in the
Value: field, type the starting number that you wish to use e.g. 1, then
click on Add, then click on OK.

Then in your document, and in the location where you want the number to
appear, go to the InsertField dialog and scroll down through the list of
fields to the DocProperty field and then in the list of properties, select
the DocNumber item from the list. When you click OK, the starting number
that you entered will appear in the document.

To get this number to be updated each time the document is opened, create
the following macro

Sub AutoOpen()
On Error GoTo EndThis 'Exits the routine if the Custom Document Property
DocNumber has not be added to the document
With ActiveDocument
.CustomDocumentProperties("DocNumber") =
..CustomDocumentProperties("DocNumber") + 1
.Range.Fields.Update
End With

EndThis:

End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"rachgg4" wrote in message
...
Hi there,

I would like to know how to have a number update automatically each time
the
document is opened. I have tried all the avenues I know and still have had
no
luck.
I am using word 2003 and have no experience with macros, however I am keen
to learn. I am struggling to get the below advice to previous users "
http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm. "
to work for me. It keeps coming up with error messages after I have
created
the macro, the main one being "Compile Error: Expected Function or
variable"
for the "Order =" and then will not attach it to my document.
I know many others have asked how to do this, I'm sorry if this is
sounding
repetitive.
Many thanks in advance to anyone able to help me.

Kind regards