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 / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Automating Seq Field Code Ticket Numbering

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig - 19 Nov 2005 21:06 GMT
I am trying to automate the numbering of tickets for a youth centre
fundraiser. There are 3 tickets on one page. I found an article in PCPlus by
Helen Bradley on using numbering tickets and ticket stubs using field code
sequential numbering which works fine. However, I wanted to create a macro
that would automate this portion: "Once you've printed the first sheet of
labels, display the field codes by pressing Alt + F9, alter the starting
number in the field code in the top right of the table, press Alt + F9 to
return to viewing the results. Choose Edit, Select All, press F9 and you're
ready to print the next lot of tickets." I tried recording a macro, but have
been stumped after many hours of working on it. To make matters worse, I
don't know macros very well either. I wanted to print the first page,
automatically change the field code in the top right of the table to 4
(increased by 3 each time), print the second page out and so on. I have to
print out 150 tickets.
Doug Robbins - Word MVP - 19 Nov 2005 22:00 GMT
The best way is to use Mailmerge to labels with an Excel data source.

Or to do it using a macro, on the first ticket on your page, where you want
the numbers to appear, insert the following field

{ DOCVARIABLE varSerialNumber \# "000" }

On the second ticket insert the following field

{ = { DOCVARIABLE varSerialNumber } + 1 \# "000" }

and on the third ticket insert

{ = { DOCVARIABLE varSerialNumber } + 2 \# "000" }

You must use Ctrl+F9 to insert each pair of field delimiters { }.  Use
Alt+F9 to toggle of the display of field codes.

Then run a macro containing the following code when that document is active.
It will ask you for the number of tickets that you want to print and then
proceed to print them.  If later you want to print some more, just open the
document and run the macro again.  It will start numbering tickets from
where the first batch finished.

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

' 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 = Val(System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "SerialNumber"))

If SerialNumber = "0" Then
   SerialNumber = 1
End If

ActiveDocument.Variables("varSerialNumber").Value = SerialNumber
Counter = 0

While Counter < NumCopies
   With ActiveDocument
       .Fields.Update
       .PrintOut
       .Variables("varSerialNumber").Value =
.Variables("varSerialNumber").Value + 3
   End With
   Counter = Counter + 3
Wend

'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
       "SerialNumber") = ActiveDocument.Variables("varSerialNumber").Value

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am trying to automate the numbering of tickets for a youth centre
> fundraiser. There are 3 tickets on one page. I found an article in PCPlus
[quoted text clipped - 13 lines]
> (increased by 3 each time), print the second page out and so on. I have to
> print out 150 tickets.
Craig - 20 Nov 2005 02:56 GMT
Hi Doug,

I get  "!Syntax Error, {" on tickets 2 and 3 on both the stub and the ticket.

Also I get a "Compile error: Expected: Expression" on
.Variables("varSerialNumber").Value =
..Variables("varSerialNumber").Value + 3

Craig

> The best way is to use Mailmerge to labels with an Excel data source.
>
[quoted text clipped - 73 lines]
> > (increased by 3 each time), print the second page out and so on. I have to
> > print out 150 tickets.
Doug Robbins - Word MVP - 20 Nov 2005 08:07 GMT
The compile error is caused because that command should all be on one line.

For the Syntax error, do you have a space between the 1 and the \ in the 1
\# "000" part of the code, likewise between the 2 and the \ on  the third
ticket?

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi Doug,
>
[quoted text clipped - 97 lines]
>> > to
>> > print out 150 tickets.
Craig - 22 Nov 2005 02:20 GMT
Doug,

There are spaces between the 1 and the \ and the 2 and \ on the second and
third tickets.

I had to remove one of the "." on the ".Variables("varSerialNumber").Value =
.Variables("varSerialNumber").Value + 3" line in order for the compile error
to disappear. I also had to add an "End Sub" after
"System.PrivateProfileString("C:\Settings.txt", "MacroSettings",
"SerialNumber") = ActiveDocument.Variables("varSerialNumber").Value" to
eliminate another error.

I'm open to suggestions about the syntax error.

Craig

> The compile error is caused because that command should all be on one line.
>
[quoted text clipped - 103 lines]
> >> > to
> >> > print out 150 tickets.
Doug Robbins - Word MVP - 22 Nov 2005 05:08 GMT
It works for me.  Perhaps the easiest thing will be for you to send me the
document so I can take a look at it.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug,
>
[quoted text clipped - 134 lines]
>> >> > to
>> >> > print out 150 tickets.
Craig - 23 Nov 2005 03:09 GMT
Doug,

How do I go about doing that? Your e-mail address on the MVP website is
labelled for paid work only.

Craig

> It works for me.  Perhaps the easiest thing will be for you to send me the
> document so I can take a look at it.
[quoted text clipped - 137 lines]
> >> >> > to
> >> >> > print out 150 tickets.
Doug Robbins - Word MVP - 23 Nov 2005 19:14 GMT
If I invite you to send something to me to look at, I won't be charging you
for it.  There is something obvious that you must remove from the email
address that you will see in the newsgroups to be able to send an email
directly to me.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug,
>
[quoted text clipped - 164 lines]
>> >> >> > to
>> >> >> > print out 150 tickets.
Graham Mayor - 20 Nov 2005 06:24 GMT
See http://www.gmayor.com/Numbered_labels.htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I am trying to automate the numbering of tickets for a youth centre
> fundraiser. There are 3 tickets on one page. I found an article in
[quoted text clipped - 11 lines]
> 4 (increased by 3 each time), print the second page out and so on. I
> have to print out 150 tickets.
Craig - 22 Nov 2005 02:23 GMT
Graham,

Thank you. I have copy of the procedure from your website. It seemed more
complicated to me. I'll see what happens first with Doug Robbin's suggestions.

Craig

> See http://www.gmayor.com/Numbered_labels.htm
>
[quoted text clipped - 13 lines]
> > 4 (increased by 3 each time), print the second page out and so on. I
> > have to print out 150 tickets.
 
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.