title: Make Individual Serial for Print documents in Word
body: <p><strong>Dear Readers</strong></p>
  <p>I am trying to make individual Serial numbers ( incrementing number) for some Forms in Microsoft Word, so we can track each one of them much simpler between people.
  I used this <a href="https://superuser.com/questions/1329783/print-serial-number-or-incrementing-number-in-word-document-footer">link</a> and it did work,
  but it needs always running Macro and I couldn't figure out how to make it automatic with just a simple Ctrl+P shortcut, so I used this <a href="https://stackoverflow.com/questions/48909968/running-a-macro-before-printing-a-word-document">second link</a> for that reason,
  finally, it looked so great but there is a problem since the second link is a just &quot;before Print&quot; code, there is always one extra print at the end since the Printing process starts exactly after macro ended. any cancel print process code out there?</p>
  <p><strong>how can I overcome this one?</strong></p>
  <p>Codes under the document</p>
  <pre><code>Private Sub Document_Open()
  Register_Event_Handler
  End Sub
  </code></pre>
  <p>Codes under the Module</p>
  <pre><code>Dim X As New EventClassModule
  Sub Register_Event_Handler()
  Set X.App = Word.Application
  End Sub
  </code></pre>
  <p>Codes under the class</p>
  <pre><code>Public WithEvents App As Word.Application
  Private Sub App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
  
  ' Run code directly inside this Sub OR
  MsgBox &quot;Before Print&quot;
  
  ' Call another Sub here, note, Sub and Module name can't match
  Call FilePrint
  ' See https://www.freesoftwareservers.com/wiki/compile-error-expected-variable-or-procedure-not-module-macros-microsoft-office-29982732.html
  End Sub
  </code></pre>
  <p>and finally Codes of FilePrint section as a Module</p>
  <pre><code>Sub FilePrint()
  Dim i As Long, j As Long
  With ActiveDocument
    j = CLng(InputBox(&quot;How many copies to print?&quot;, &quot;Print Copies&quot;))
    For i = 1 To j
      With .CustomDocumentProperties(&quot;Counter&quot;)
        .Value = .Value + 1
      End With
      .Fields.Update
      ActiveDocument.PrintOut Copies:=1
    Next
    .Save
  End With
  End Sub
  </code></pre>