PDA

View Full Version : [SOLVED:] Need to update Revision Number by choice.



geedee65
09-11-2007, 06:12 AM
I currently use the Revison Number field (from 'Properties') in the document's footer as part of a Document Control system.
What i would like to do is only to update the Revision Number when I want it to (eg with a Yes/No message box) and not every time the document is saved.
In essence a document can be saved many times before it is approved and released, so the Revision Number of a documnet suddenly jumps by 10, 20 etc!

Can this be done?

fumei
09-11-2007, 12:08 PM
There can be much confusion between Revision Number (which you see in Document Properties), and Version (which you can see in File > Versions).

They are very different.

MsgBox "Revision Number: " & _
ActiveDocument.BuiltInDocumentProperties("Revision Number") _
& vbCrLf & _
"Version Number: " & ActiveDocument.Versions.Count
could display something like:

Revision Number: 10
Version Number: 0

The Revision Number increments with every Save. The Version Number ONLY increments if you tell Word to do so.

You can add comments to Versions. Either through the File > Versions dialog, or with code.ActiveDocument.Versions.Save Comment:="Ends at Stop Here at Version 1"If you ran the above code, then the previous code (displaying Revision Number and Version Number) would show:

Revision Number: 10 (or whatever)
Version Number: 1

This can be VERY VERY handy, as you can Open Versions.

Say you have a document with (to keep it simple) the following text ONLY.

"This is sentence one."

Save it with a name. Now save a Version. Either use the File > Version dialog, or by code:


ActiveDocument.Versions.Save Comment:="Only text is This is sentence one."


OK? Now add some text. The document now has:

"This is sentence one.

Added another sentence."

Save it. Close Word (just to demostrate fully).

Open Word. Open the document. It will show:

"This is sentence one.

Added another sentence."

Now, run this:
Sub OpenV1()
ActiveDocument.Versions(1).Open
End Sub
You will get a NEW document window with a document showing:

"This is sentence one."

Because THAT is Version 1. The title bar will show:

"Filename, versionDate, version"

This is NOT a saved file. Adding Versions includes that version content within the document file, via an internal tracking of changes. So be careful. If it is just text, this is not much of an issue. Note that these internal changes are NOT Track Changes. Versions works whether you have Track Changes on or off. It is completely independent.

Versions is read-only. However, you can do neat things with it.

Sub GetAVersion()
Dim response
Dim j As Long
If ActiveDocument.Versions.Count > 1 Then
For j = 1 To ActiveDocument.Versions.Count
response = MsgBox("Version " & j & " Comment: " _
& vbCrLf & ActiveDocument.Versions(j).Comment & _
vbCrLf & "Do you want to open this Version?", vbYesNo)
If response = vbYes Then
ActiveDocument.Versions(j).Open
Exit Sub
End If
Next
End If
End SubThis would display all the Versions Comments, and you could select one to open.

NOTE! Each Version has its own data!


Dim aVersion As Version
Dim j As Long
If ActiveDocument.Versions.Count > 1 Then
For Each aVersion In ActiveDocument.Versions
j = aVersion.Index
MsgBox "Version " & j & " Saved by " & _
aVersion.SavedBy & " on " & aVersion.Date & _
vbCrLf & "Comment: " & aVersion.Comment
Next
End If
would display data for each different Version.

Hopefully this may help. You may want to think about using Versions.

I don't know off-hand any way to prevent the Revisions value from incrementing with every Save.

geedee65
09-12-2007, 12:49 AM
Thanks fumei,
yep, I agree you should use the version option whenever possible.
The problem I have is that the software (Axion 4TQ) we use to distribute process flows and related forms looks to the field 'Revision Number' or a custom property (File / Properties / Custom tag) called 'Version' (which you have to enter manually) to show in the system what the current version number is.

All the document control info is contained in a table within the footer, eg. Document Number, Version, Author, Status & Approved Date.

I tried using the custom property 'Version', but that relied upon authors inputting the next version number manually, which of course failed due to people forgetting to update the version number.

So I started to use the 'Revision Number' field, which some managers dislike when they see it jumping up by 20 after they have made a few "minor modifications".

If a go back to the custom property 'Version', is it possible to have a Yes/No option to increase this by 1 pop up when the document is closed?

Or am I just stuck? :banghead:

I've also requested (to Axion) that the software look at the Version Number from File / Versions, but I don't think that will happen!

geedee65
09-16-2007, 02:24 PM
Can anyone tell me how you,

a) display a field from the "File / Properties / Custom" tab in a table in the footer?
b) use a Yes/No message box to change that field?

TonyJollans
09-16-2007, 03:49 PM
a) use a DocProperty Field (Insert > Field)
b) the code you need to update the property is:

ActiveDocument.CustomDocumentProperties("your property name") = "New value"
I'm sure you can do your own message box.

geedee65
09-17-2007, 05:22 AM
Thanks for that Tony,

One more question, is it possible to display the version number (File / Versions) as a field in the document?

TonyJollans
09-17-2007, 09:21 AM
Not really. See http://word.mvps.org/FAQs/General/DisplayVersions.htm

fumei
09-17-2007, 09:58 AM
That is an excellent article and well worth reading. It points out the serious flaw to using Versions. And the value of using a Document Variable instead.

What this really means is you need to think about what, exactly, are your requirements.

geedee65
09-17-2007, 03:38 PM
That's a very good article ....... plus the site contains some really useful information!

I think I will stick with saving a copy of each version to an archive folder and use the custom properties to generate any document control fields that are not available in the normal document properties.

Thanks fumei & Tony.