View Single Post
 
Old 06-11-2019, 04:17 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,342
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Private Sub Document_New()
Application.ScreenUpdating = False
Dim InvNum As String
With ThisDocument
  InvNum = .CustomDocumentProperties("InvNum") + 1
  .CustomDocumentProperties("InvNum") = InvNum
  .Save
End With
With ActiveDocument
  'Update the value stored in the document property
  .CustomDocumentProperties("InvNum") = InvNum
  'Update the fields in the document
  .FormFields("ECNNUM").Result = InputBox("Please enter the ECN number. ")
  .Fields.Update
End With
Application.ScreenUpdating = True
With Application.Dialogs(wdDialogFileSaveAs)
  .Name = "c:\My Documents\SaveExample.docx"
  .Format = wdFormatXMLDocument
  .Show
End With
End Sub
I note that you commented-out the .Save for the template. Do that and the numbers won't increment unless you tell Word to save the changes to the template when you exit Word. Furthermore, in a multi-user environment, that promotes the duplication of numbers if multiple users are creating these documents at the same time.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote