microsoft word 2000 help
Author
Discussion

g4ry13

Original Poster:

19,921 posts

272 months

Friday 9th January 2004
quotequote all
I have Microsoft word 2000, and am making a document which is supposed to give the customer a quote number and reference for their transaction. Is there any way of enabling the document to generate the next number so i don't have to create the number manually. I assume you have to create a macro or something.

Appreciate any replies.

Thanks Gary

>>> Edited by g4ry13 on Friday 9th January 12:45

tjmurphy

239 posts

280 months

Saturday 10th January 2004
quotequote all
If you're talking about something like a sequential quote number (across different documents, rather than sequential numbering within the one document) I think you're right, you need a macro.

You can create a macro which stores something in your PCs registry - I'm thinking this would be your quote number. Then you need a macro in your document which gets the number, adds 1 to it, puts the new number in your document and stores it back in the registry.

Or, maybe this will get you started. I think you need to put it into the Normal template so that it's accessible to all your documents, but that's the bit of Word coding I'm not sure of.

Public Sub GetNextNumber()
Dim sNumber As String ' For the registry the item has to be string

sNumber = GetSetting("QuoteSystem", "Storage", "Value")

If sNumber = "" Then
' If nothing found then presumably this is the first time
' running the program so, start at 1
SaveSetting "QuoteSystem", "Storage", "Value", "1"
sNumber = 1
Else
' Otherwise, get the number and add 1 to it.
' Put it back in the registry
sNumber = Str(Val(sNumber) + 1)
SaveSetting "QuoteSystem", "Storage", "Value", sNumber
End If

' Next bit inserts after the current selection in your doc
Selection.InsertAfter sNumber

End Sub

g4ry13

Original Poster:

19,921 posts

272 months

Saturday 10th January 2004
quotequote all
Thanks, i'll give it a try on monday. I don't think it's very important anyway.

Thanks again