View Single Post
 
Old 12-17-2018, 06:14 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I would be using a content control linked to a built-in document property for the Number, and a SaveDate field for the date.

To add the content control, put your cursor in the header and type in "No. " and then go to Insert > Quick Parts > Document Property > Category.

To add the SaveDate field, put your cursor in the header and go to Insert > Quick Parts > Field > SaveDate (and chose the relevant Date Format), click OK

The final part is to add a macro which can update the Category property and save the file to adjust the date.
Code:
Option Explicit

Sub IncrementNumber()
  Dim i As Integer
  i = Val(ActiveDocument.BuiltInDocumentProperties("Category").Value) + 1
  ActiveDocument.BuiltInDocumentProperties("Category").Value = i
  ActiveDocument.Save
  UpdateAllFields
End Sub

Sub UpdateAllFields()
  Dim oStory As Range
  For Each oStory In ActiveDocument.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
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote