Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Leamington Spa, Warwickshire, England
    Posts
    136
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have been asked if it is possible when a particualr document in Word is opened if it is possible to generate a number so for example
    Gill opens the document and a n order ref number of R1 is created
    maggie opens the document and an order number of R2 is created and so on....

    Is this a possibility?

    Thanks

    michelle

  2. #2
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='meames' post='792412' date='07-Sep-2009 06:59']I have been asked if it is possible when a particualr document in Word is opened if it is possible to generate a number so for example
    Gill opens the document and a n order ref number of R1 is created
    maggie opens the document and an order number of R2 is created and so on....

    Is this a possibility?

    Thanks

    michelle[/quote]
    The following code should do the trick when placed within the "ThisDocument" module.
    Code:
    Private Sub Document_Open()
    	 With ThisDocument
    		 On Error Resume Next
    		 .Variables("OpenInc") = .Variables("OpenInc") + 1
    		 If Err Then
    			 On Error GoTo 0
    			 .Variables.Add "OpenInc", 1
    		 End If
    	 End With
    	 MsgBox "This document has now been opened " & _
    		 ThisDocument.Variables("OpenInc").Value _
    		 & " times.", vbInformation, "FYI"
     End Sub
    Regards
    Don

  3. #3
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Leamington Spa, Warwickshire, England
    Posts
    136
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can i get that number to appear in the doc?

    thanks

    Michelle

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='meames' post='792422' date='07-Sep-2009 09:04']Can i get that number to appear in the doc?

    thanks

    Michelle[/quote]

    • Pull down: Insert > Field
    • In the Field names list, select DocVariable
    • In the New name box type the variable name (OpenInc)
    Alt + F9 with the resulting field selected will switch between code and results.
    Regards
    Don

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Since this request most commonly arises with invoice numbers or Bates stamp numbers, you could use those terms for further searching if the above method does not work for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •