![]() |
|
#13
|
|||
|
|||
|
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
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. Last edited by eduzs; 03-07-2018 at 05:06 AM. |
| Tags |
| macro, word 10 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Increase number in cell, based on value in adjacent cell | scottyb | Excel | 3 | 02-02-2017 03:51 AM |
| How to find number of coma and then add that number of rows in word using macro? | PRA007 | Word VBA | 7 | 05-27-2015 10:45 PM |
Global macro across a number of different word files
|
daffy | Word VBA | 6 | 07-08-2014 05:42 PM |
| Createing Macro to Increase Margin by 1pt | thundercats9595 | Word VBA | 2 | 01-29-2014 12:36 PM |
Increase serial number for every print
|
atomtm | Word | 1 | 06-15-2012 05:39 AM |