View Single Post
 
Old 03-07-2018, 02:55 AM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Try this:

1st Type this in the document:

"Version #", CTRL+F9 (to insert a field), "{ DOCVARIABLE VNUM }"

Put his code in a module:

Code:
Sub Increment()

On Error Resume Next
With ActiveDocument
    .Variables.Add ("VNUM")
    On Error GoTo 0
    If IsNumeric(.Variables("VNUM")) = False Then
        .Variables("VNUM") = 1
    Else
        If .Saved = False Then
            .Variables("VNUM") = .Variables("VNUM") + 1
        Else
            MsgBox "No changes!"
        End If
    End If
    .Fields.Update
    .Save
    .Close
End With

End Sub
Assign this macro to CTRL+M keyboard shortcut.

The Ctrl+W is really necessary? Why not just save and close the document ?

Test before use, backup your files before, use at your own.
__________________
Backup your original file before doing any modification.

Last edited by eduzs; 03-07-2018 at 05:06 AM.
Reply With Quote