Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Numbering / July 2004

Tip: Looking for answers? Try searching our database.

Help w/ seq numbering

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Texter - 29 Jul 2004 20:01 GMT
I merge data from Access into a Word document to generate contracts. Each
record (person) gets a separate contract. Each contract should have a unique
sequential number assigned to it. I found the following code from MVP.
However it assigns the same number to every contract. Any suggestions?

Dim Message As String, Title As String, Default As String, NumCopies As Long

Dim Rng1 As Range

'Set prompt.

Message = "Enter the number of copies that you want to print"

'Set title.

Title = "Print"

'Set default.

Default = "1"

'Display message, title, and default value.

NumCopies = Val(InputBox(Message, Title, Default))

SerialNumber = System.PrivateProfileString("C:\Settings.txt",
"MacroSettings", "SerialNumber")

If SerialNumber = "" Then

   SerialNumber = 1

End If

Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range

Counter = 0

While Counter < NumCopies

   Rng1.Delete

   Rng1.Text = SerialNumber

   ActiveDocument.PrintOut

   SerialNumber = SerialNumber + 1

   Counter = Counter + 1

Wend

'Save the next number back to the Settings.txt file ready for the next use.

System.PrivateProfileString("C:\Settings.txt", "MacroSettings",
"SerialNumber") = SerialNumber

'Recreate the bookmark ready for the next use.

With ActiveDocument.Bookmarks

   .Add Name:="SerialNumber", Range:=Rng1

End With

ActiveDocument.Save

Thanks for your help!!

Lance
Doug Robbins - 31 Jul 2004 00:51 GMT
Hi Lance,

See the article "Creating sequentially numbered documents (such as
invoices)" at:

http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

Or, probably better to add a field to the data source to contain the numbers
and then merge that field into the documents.
Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>I merge data from Access into a Word document to generate contracts. Each
> record (person) gets a separate contract. Each contract should have a
[quoted text clipped - 69 lines]
>
> Lance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.