Share via

Inserting Document ID or other reference number into Word 2011

Anonymous
2012-08-01T12:00:44+00:00

Hi there, does anyone know if its possible to automatically insert a unique auto-incrementing reference number such as Document ID, into each word document, maybe into the header or footer info, so that each new Word document displays a unique reference number?

Seen it in database records e.g. a purchase order but can't see any options in Word for Mac...

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2012-08-01T13:03:33+00:00

    Yes, it's possible.  You need to code it up yourself:

    http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

    However, you need to modify that code, because there's a bug in Word 2011 that means PrivateProfileString does not work.

    See http://answers.microsoft.com/en-us/office/forum/officeversion_other-customize/system-privateprofilestring-not-working/9bb513ef-39e2-4346-bbc5-07fa43326028

    You need to use this line instead:

    Call SaveSetting("My_App","ThisSection", "ThisKey", "This is the string to save")

    Hope this helps

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2012-08-01T15:11:46+00:00

    Thanks very much, although I must admit this is still beyond my knowledge of VB/Macros. Where would I put the Call Savesetting line as there are 2 occurences of System.PrivateProfileString. Sorry to take up your time,

    Sub AutoNew()

    Order = System.PrivateProfileString("C:\Settings.Txt", _

    "MacroSettings", "Order")

    If Order = "" Then

    Order = 1

    Else

    Order = Order + 1

    End If

    System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _

    "Order") = Order

    ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "00#")

    ActiveDocument.SaveAs fileName:="path" & Format(Order, "00#")

    End Sub

    Was this answer helpful?

    0 comments No comments