incrementing invoice number on word template

A

allan

Hi
I am trying to create a word template that has a number that increments with
each new document created.
So far I have worked from kb212686 and that is fine, but I would like to
have the number so that it is to five signicant digits.
eg
5 would be 00005
101 would be 00101
and so forth
If anyone has got any ideas on how to achieve this I would be very
appreciative to know.
 
D

Dave Lett

Hi Allan,

Does the following routine help you work out how to increment to five
significant digits?

Dim iCount As Integer
Dim sCount As String
For iCount = 1 To 10
If Len(iCount) < 5 Then
Select Case Len(CStr(iCount))
Case 1
sCount = "0000" & iCount
Case 2
sCount = "000" & iCount
''' and so on through 4 cases
Case Else
End Select
End If
Debug.Print sCount
Next iCount
 
A

allan

Hi Dave,

I got reply in another section and was directed to
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

This did the trick perfectly. All I had to do was edit it for 5 sig figures
instead of 3.
I had a play with your code and it almost worked (doubtless something I am
doing), so I will keep it aside for a rainy day and have it as an alternative.

Many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top