Results 1 to 12 of 12
  1. #1
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Autonumber (2003 SP2)

    I'm having to create a certificate form & wondered if there is anyway of having a field that will automatically create a new unique number, in the same manner that Access does with autonumber in a table?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Autonumber (2003 SP2)

    See Creating sequentially numbered documents (such as invoices) on the Word MVP site, or <post:=665,053>post 665,053</post:>.

  3. #3
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Cheers. I figured there was something, just couldn't find it.

    Many thanks.

  4. #4
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Well I'm going to need some more help.

    I wanted to use this on a locked form (allowing users to tab between relevant parts to be edited), but that raises error 4605, relating to protected area of document.

    If I remove the lock, then the autonumber always comes up as 1 {scratches head}.

    I've included the .dot. N.B. the path for the .txt file is due to work PC's having C: hidden.
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Autonumber (2003 SP2)

    Your template doesn't contain any code. <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  6. #6
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Ooer, that's odd. Mind you I've never done any of this in Word, I may have the code on the PC.

    Let's see if this works.
    Attached Files Attached Files

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Autonumber (2003 SP2)

    Still no code. I suspect that you stored the code in your Normal.dot instead of in the template, where it belongs. Take a look in the Visual Basic Editor to see where the code is. You can drag a module from one document/template to another in the Project Explorer on the left hand side.

  8. #8
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Oh $%!"$$^%^.

    Right, there looks to be 3 projects(?) in the left hand panel. So to overkill this, I've stuck a copy in each.
    Attached Files Attached Files

  9. #9
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Aha, found one part of the problem; I'd got 2 different file paths (doh!).

    However, the numbering will only work with an un-protected form. Is there a work around? Can this be made to work in Excel instead??

    I'm trying to make sure we don't have duplicates, without going into Access (it's been frowned on, at the moment).

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Autonumber (2003 SP2)

    1) Your For Woodys.dot is not a real template. It is a Word document (.doc) whose extension has been changed to .dot. Instead, you should use File | Save As and select Document Template (*.dot) from the dropdown at the bottom of the Save As dialog.

    2) The code contains an inconsistency: the path is first c:IncrementNumber.txt, then N:IncrementNumber.txt. Use either c: or N:

    3) There is a reference to a template GL cert Template.dot in Tools | References in the Visual Basic Editor. Unless you really need this reference, you should clear its check box.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Autonumber (2003 SP2)

    You could unprotect the document in the code, insert the number, then protect it again:

    ActiveDocument.Unprotect
    Selection.GoTo What:=wdGoToBookmark, Name:="obmkNumber"
    Selection.TypeText sUsageCount
    ActiveDocument.Protect wdAllowOnlyFormFields

  12. #12
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autonumber (2003 SP2)

    Right, got there.

    The protection code was the last bit needed.

    Thank you very much.

Posting Permissions

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