The macro checks the names of the bookmarks and not the values they contain.
The macro is simply looking for bookmarks called A, B, C etc which it loads
in turn into the variable each overwriting the previous letter, and as they
are in alphabetical order, the last letter is the one that the variable
retains ... until you add another bookmark and re-run the macro.
If you want to send me a sample of your document (use the link on the home
page of my web site - and remove any sensitive data) I would be able to see
exactly what you are doing and maybe suggest a workaround to achieve what
you want. At the moment I am not 100% clear on how you are using the version
information - the bookmark(s) and the 'field'. It may, for example not be
necessary top use a bookmark at all - you could simply write the letter to a
docvariable with a macro and reproduce it with a docvariable field
or
If there is only one letter in the document at a time, format that letter
with a unique character style (that can be the same as the underlying style
except for the name) and reproduce the content of the style - the letter -
in the header using a Styleref field.
If you merely want to reflect the revision letters in the variable then the
following macro will do that - up to a maximum of 7 letters A- G. Run this
macro in the the last saved version of the document. When you save it
increments the letter and saves the document with the same filename in the
same folder with the addition of the incremented letter e.g.
C:\Path\filename revision A.doc
Sub FileSave()
Dim oDoc As Document
Dim oVars As Variables
Dim oStory As Range
Dim sFname As String
Set oDoc = ActiveDocument
Set oVars = oDoc.Variables
On Error Resume Next
If oVars("varLetter").Value = "" Then
oVars("varLetter").Value = " "
End If
If Len(oDoc.Path) = 0 Then
oDoc.Save
End If
sFname = Left(oDoc.FullName, Len(oDoc.FullName) - _
(Len(oDoc.FullName) - InStrRev(oDoc.FullName, ".") + 1))
Select Case oVars("varLetter").Value
Case " ": oVars("varLetter").Value = "A"
Case "A"
oVars("varLetter").Value = "B"
sFname = Replace(sFname, " Revision A", "")
Case "B"
oVars("varLetter").Value = "C"
sFname = Replace(sFname, " Revision B", "")
Case "C"
oVars("varLetter").Value = "D"
sFname = Replace(sFname, " Revision C", "")
Case "D"
oVars("varLetter").Value = "E"
sFname = Replace(sFname, " Revision D", "")
Case "E"
oVars("varLetter").Value = "F"
sFname = Replace(sFname, " Revision E", "")
Case "F"
oVars("varLetter").Value = "G"
sFname = Replace(sFname, " Revision F", "")
Case Else: MsgBox "Maximum permitted revision already added." & vbCr & _
"Revision letter will not be updated" & vbCr & _
"Document will not be saved", vbInformation, "Revisions"
Exit Sub
End Select
For Each oStory In oDoc.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
oDoc.SaveAs sFname & " Revision " & oVars("varLetter").Value
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>