Entry tags:
Google fu fail
I'd like to create a Word document containing a numeric field that increments every time the file is opened.
I must be missing something, but all I'm finding online are guides based on Word 2003 that involve page-long macros and editing the register....
Does anyone know how do to do? Surely it must be possible, with some sort of fiddling with field codes? It's possible to create a custom field to be a counter, and to set things like date fields to auto-update on opening, so can I just combine the two?
It's years since I did anything serious in Word, and it was always my weakest of the three!
I must be missing something, but all I'm finding online are guides based on Word 2003 that involve page-long macros and editing the register....
Does anyone know how do to do? Surely it must be possible, with some sort of fiddling with field codes? It's possible to create a custom field to be a counter, and to set things like date fields to auto-update on opening, so can I just combine the two?
It's years since I did anything serious in Word, and it was always my weakest of the three!

no subject
http://www.msofficeforums.com/word/7034-does-word-have-option-update-fields-automatically.html
no subject
I'm a little bemused that it's not easier, I must admit!
no subject
There is a document property called Revision that auto-increments every time the document is saved. If you are only concerned with changes to the document, that might be what you want. You could also track the TotalEditingTime value which shows how many minutes have been spent editing the document.
Alternatively, if really need to know how many times it's been opened, create a custom property in the document and make it a number rather than text. Let's call it "Test". Then go into Developer/Visual Basic and add the following to the document:
Private Sub Document_Open()
ThisDocument.CustomDocumentProperties("Test") = ThisDocument.CustomDocumentProperties("Test") + 1
End Sub
The problem with this is that you have to save it as a macro-enabled document, and someone can open the document with macros disabled which will stop the number incrementing. Also, if you close the document without saving changes, it doesn't save the changed value (hence, I suspect, the code in the examples you found to save the number in the registry instead of in the document).
You can include a field with this property in the document (Insert/Quick Parts/Field then select Document Information, DocProperty, Test), but you may need to update the field before it shows the correct value.