For this to work in Word, you'd need to store the last-used number in a document property or variable for retrieval. The code to do this might look like:
Code:
Sub InsertNextID()
Dim ID As Long, i As Long, bFnd As Boolean
Const strID As String = "MaxID"
bFnd = False
On Error Resume Next
With ActiveDocument
For i = 1 To .Variables.Count
If .Variables(i).Name = strID Then
bFnd = True
ID = .Variables(strID).Value + 1
Variables(strID).Value = ID
Exit For
End If
Next
If bFnd = False Then
ID = InputBox(Prompt:="Please input the First ID #", _
Title:="ID Creation", Default:=1)
.Variables.Add Name:=strID, Value:=ID
End If
Selection.Text = ID
End With
ErrExit:
End Sub
And the code you'll inevitably need to reset that ID might look like:
Code:
Sub IDReset()
Dim ID As Long, i As Long
Const strID As String = "MaxID"
On Error Resume Next
With ActiveDocument
For i = 1 To .Variables.Count
If .Variables(i).Name = strID Then
ID = .Variables(strID).Value
ID = InputBox(Prompt:="Please input the Reset ID #," & vbCr & _
"equal to the last valid ID #", Title:="ID Creation", Default:=ID)
Variables(strID).Value = ID
Exit For
End If
Next
End With
End Sub