Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Microsoft Support > Microsoft Office support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Microsoft Office support MS Office support forum

Reply
 
LinkBack Thread Tools
Old 04-13-2009, 02:53 PM   #1 (permalink)
Registered User
 
Join Date: Apr 2009
Posts: 4
OS: xp - Service Pack 3


Question Creating Sequentially numbered documents in Word 2007

Currently we have rental forms that get filled out everytime one of our rental vehicles gets rented. In the past these forms have come pre-numbered from a local printing company. To save the company money, I was going to re-create the form in Word so that we didn't have to order them. Also, this way the form will look much tidier as the information will not have to be handwritten in. The only problem is, how do I add a sequential number to the top of the form. I need the first form to be say 03051, and then everytime the form is opened and saved thereafter, I need it to sequentially go up in numbers.
If this is even possible, I would only like it to give it the next number if the form is actually saved, not just opened, as sometimes the form will be opened, but not saved, and in that case I don't want it to get the next number.

Any help would be much appreciated

Alanda
alantz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 04-13-2009, 09:48 PM   #2 (permalink)
TSF Enthusiast
 
Join Date: Apr 2008
Location: Australia
Posts: 563
OS: Vista


Re: Creating Sequentially numbered documents in Word 2007

Hi Alanda,

To do this, should use a document template with some vba code to:
. run upon creation of a new document
. open a nominated text file containing the document number,
. insert the number into the new document (eg insert the number into a Custom Document Property that can then be referenced via a DOCPROPERTY field in the document)
. increment the number in the text file, then close it.

Although you could simply increment a number in an existing document, you really should use a template (ie .dot file) as the base from which your agreements are made.
__________________
Cheers
macropod
(MS MVP -Word)
macropod is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-14-2009, 07:37 AM   #3 (permalink)
Registered User
 
Join Date: Apr 2009
Posts: 4
OS: xp - Service Pack 3


Re: Creating Sequentially numbered documents in Word 2007

That all sounds like a great idea, but unfortunately I am an amateur when it comes to VBA code. Could you show me how to write the code, and how to put it into the document.?
alantz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-20-2009, 05:41 AM   #4 (permalink)
TSF Enthusiast
 
Join Date: Apr 2008
Location: Australia
Posts: 563
OS: Vista


Re: Creating Sequentially numbered documents in Word 2007

Hi Alanda,

Sorry about the delay in replying.

Here's some code for inserting and incrementing a number from a text (ini) file:
Code:
Sub AutoNew()
Dim InvoiceFile As String
Dim InvNum As String
'Save ini file in the Word startup folder.
InvoiceFile = Options.DefaultFilePath(wdStartupPath) & "\Invoice.ini"
'or, by using the following line, the Workgroup folder
'InvoiceFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\Invoice.ini"
InvNum = System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum")
'If there is no InvoiceNumber reference in the ini file
'Create one and set the number to 1, otherwise increment the number
If InvNum = "" Then
    InvNum = 1
Else
    InvNum = InvNum + 1
End If
System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum") = InvNum
With ActiveDocument
  .CustomDocumentProperties("InvNum") = InvNum
  .Fields.Update
End With
End Sub
To use the code, you need to open your invoice template and add the macro to it. For instructions on how to do this, see: http://www.gmayor.com/installing_macro.htm.

Then, go to File|Properties|Custom and add a document property named 'InvNum'. Next, in the body of the invoice template, position the insertion point where you want the invoice number to appear and press Ctrl-F9 to create a pair of field braces (ie '** }') and type 'DOCPROPERTY InvNum' between the field braces, thus '{DOCPROPERTY InvNum}'. If you want to force the Invoice # to display leading 0s (eg 01234), add '\# 0000' to the field code, thus: '{DOCPROPERTY InvNum \# 0000}'.

Finally, save the template as a Word document Template (ie with a '.dot' extension, via File|Save As), named 'Invoice' (or another suitable name).

Now, whenever you want to create a new Invoice, simply go to File|New and select 'Invoice' (or your preferred name). You'll get an invoice with the next available number. If you need to set the initial invoice #, or reset it, you'll find a file named 'Invoice.ini' in your Word Startup folder (to find where this is stored, look under Tools|Options|File Locations). In case you need it, there's a commented-out line to store the 'Invoice.ini' in your Word Workgroup folder instead, so that others in your workgroup can access it also.
__________________
Cheers
macropod
(MS MVP -Word)

Last edited by macropod; 04-20-2009 at 05:46 AM.
macropod is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-28-2009, 02:39 PM   #5 (permalink)
Registered User
 
Join Date: Apr 2009
Posts: 4
OS: xp - Service Pack 3


Re: Creating Sequentially numbered documents in Word 2007

I really appreciate the help you have given me on this issue. I think I have almost got this invoice numbering thing working. Right now, everytime I open the file, it gives it the next number, even if I say 'NO' to saving it. Is there any way that if a person answers 'NO' to the prompt when it asks you if you want to save the document, then the next time you open the document, it will give it that same number again, rather than jumping to the next number?
Also how do I make the document numbering start at 03101?
alantz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-28-2009, 05:37 PM   #6 (permalink)
TSF Enthusiast
 
Join Date: Apr 2008
Location: Australia
Posts: 563
OS: Vista


Re: Creating Sequentially numbered documents in Word 2007

Hi Alanda,

Unless you want a prompt every time an invoice document is created, there's really no practical way to prevent the number from incrfementing - it's done when the document is created.

However, as indicated in my previous post, if you need to set the initial invoice #, or reset it, you'll find a file named 'Invoice.ini' in your Word Startup folder (to find where this is stored, look under Tools|Options|File Locations). Simply open that file with notepad (eg by double-clicking on it) and make the invoice # whatever you want it to be.

If you want to do some experimentation with your Invoce document (eg to change the layout), you could simply rename 'Invoice.ini' temporarily (eg 'xInvoice.ini'). Word will create a new one, starting at # 1, but you can delete this when you're finished and change the 'xInvoice.ini' file's name back to 'Invoice.ini' again, so that the invoice numbering picks up from where it left off prior to the experimentation.
__________________
Cheers
macropod
(MS MVP -Word)
macropod is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-04-2009, 10:27 AM   #7 (permalink)
Registered User
 
Join Date: Apr 2009
Posts: 4
OS: xp - Service Pack 3


Re: Creating Sequentially numbered documents in Word 2007

This is going to sound like a really silly question, but where is the Word Startup folder? I am having a heck of a time trying to figure this out. When you say to look under Tools/Options/File Locations, I don't know where you mean. Which tools are you refering to?
Also a prompt wouldn't be such a bad thing in this case. When the user goes to save the form, would it be possible then to put the prompt asking the user if they want to assign this form the next number? If they say no, then it doesn't assign the next number? If this is possible, how would you do it?
Thanks again for your time.
alantz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-04-2009, 04:47 PM   #8 (permalink)
TSF Enthusiast
 
Join Date: Apr 2008
Location: Australia
Posts: 563
OS: Vista


Re: Creating Sequentially numbered documents in Word 2007

Hi Alanda,

Look in Word's menu, under Tools|Options|File Locations!

As forthe prompt, I think you're missing the point that the 'Invoice.ini' file gets updated with the next number immediately the document is created. Thus, it's not a case of being able to prompt whether to increment the number at the time the file gets saved.

What you could do instead is add the following macro to your Normal.dot template:
Code:
Sub RestInvoiceNumber()
Dim InvoiceFile As String
Dim InvNum As String
InvoiceFile = Options.DefaultFilePath(wdStartupPath) & "\Invoice.ini"
'or, if using a Workgroup folder
'InvoiceFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\Invoice.ini"
InvNum = System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum")
InvNum = Trim(InputBox("What is the last valid Invoice Number?" & vbCrLf & _
  "The current number is: " & InvNum))
If IsNumeric(InvNum) Then
  System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum") = CInt(InvNum)
  End
Else
  If InvNum = "" Then End
End If
MsgBox "Renumbering error, please try again."
End Sub
This enables you to re-set the Invoice Number if you need to, without manually finding & editing the 'Invoice.ini' file.
__________________
Cheers
macropod
(MS MVP -Word)
macropod is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 04:37 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85