Creating Sequential Numbering in Labels 
Author Message
 Creating Sequential Numbering in Labels

Hi Folks,

I am printing A4 labels and want to add some sequntial numering.

For instance

01/102/G01 - G20

I have created a doucment of Avery L7160 labels, whats the easiest way
to add the numbering? I assume a simple bit of code can do it, but
could somebody help me out please?

Thanks

- Al



Wed, 20 Aug 2003 07:40:05 GMT  
 Creating Sequential Numbering in Labels
Hi Al,

The following code will add a number at the start of each label, beginning
with 00001 and incrementing this value for each succeeding label.

To change the starting value or the number of digits, tweak these items in
the code. Warning! The number of digits should be kept below 10.

The code isn't too hard to follow. I haven't commented it but you can always
post back for help if you need some. The code relies on the fact (I think
it's a fact) that the first cell in each table represents an actual label,
whereas other cells in the table, if sized differently from the first cell,
do NOT represent labels but just spacers.

Here ya go:

Sub NumberTheLabels()
Dim oTable As Table
Dim oCell As Cell
Dim StartAt As Long
Dim NumberOfDigits As Integer
Dim LabelString As String
Dim LabelValue As Long
Dim LoopCounter As Integer
Dim FirstCellWidth As Long
Dim FirstCellHeight As Long

StartAt = 1
NumberOfDigits = 5

LabelValue = 1
For LoopCounter = 1 To NumberOfDigits
LabelValue = LabelValue * 10
Next LoopCounter

LabelValue = LabelValue + StartAt

If ActiveDocument.Tables.Count = 0 Then
MsgBox "Couldn't find any labels"
End If

For Each oTable In ActiveDocument.Tables
FirstCellWidth = oTable.Range.Cells(1).Width
FirstCellHeight = oTable.Range.Cells(1).Height
For Each oCell In oTable.Range.Cells
If oCell.Width = FirstCellWidth _
And oCell.Height = FirstCellHeight Then
LabelString = Mid(Format(LabelValue), 2)
oCell.Range.InsertBefore LabelString
LabelValue = LabelValue + 1
End If
Next oCell
Next oTable

End Sub

--
Bill Coan
Fill out letters, contracts, forms, in seconds! DataPrompter
prompts you for data, inserts it, updates it automatically.
Details at http://www.wordsite.com/DataPrompter.html

Quote:




Quote:
> Hi Folks,

> I am printing A4 labels and want to add some sequntial numering.

> For instance

> 01/102/G01 - G20

> I have created a doucment of Avery L7160 labels, whats the easiest way
> to add the numbering? I assume a simple bit of code can do it, but
> could somebody help me out please?

> Thanks

> - Al



Wed, 20 Aug 2003 09:44:22 GMT  
 Creating Sequential Numbering in Labels
Hi Bill,

Thanks for the code. Have not had time to check it out yet, but I am
sure it will work.

The labels I am using do have spacer cells...

Now to a slighty different topic, I have created a template for a
legal statement. I have put a header on the first page, but if the
doucment ends up going to 2 pages or more, I don't want any header.

I know how to manually fix this by creating a section break, and
making the header so its not the 'same as previous'.

But how would you set this up with a template.?

Cheers

- Al

On Fri, 2 Mar 2001 19:44:22 -0600, "Bill Coan [Word MVP]"

Quote:

>Hi Al,

>The following code will add a number at the start of each label, beginning
>with 00001 and incrementing this value for each succeeding label.

>To change the starting value or the number of digits, tweak these items in
>the code. Warning! The number of digits should be kept below 10.

>The code isn't too hard to follow. I haven't commented it but you can always
>post back for help if you need some. The code relies on the fact (I think
>it's a fact) that the first cell in each table represents an actual label,
>whereas other cells in the table, if sized differently from the first cell,
>do NOT represent labels but just spacers.

>Here ya go:

>Sub NumberTheLabels()
>Dim oTable As Table
>Dim oCell As Cell
>Dim StartAt As Long
>Dim NumberOfDigits As Integer
>Dim LabelString As String
>Dim LabelValue As Long
>Dim LoopCounter As Integer
>Dim FirstCellWidth As Long
>Dim FirstCellHeight As Long

>StartAt = 1
>NumberOfDigits = 5

>LabelValue = 1
>For LoopCounter = 1 To NumberOfDigits
>LabelValue = LabelValue * 10
>Next LoopCounter

>LabelValue = LabelValue + StartAt

>If ActiveDocument.Tables.Count = 0 Then
>MsgBox "Couldn't find any labels"
>End If

>For Each oTable In ActiveDocument.Tables
>FirstCellWidth = oTable.Range.Cells(1).Width
>FirstCellHeight = oTable.Range.Cells(1).Height
>For Each oCell In oTable.Range.Cells
>If oCell.Width = FirstCellWidth _
>And oCell.Height = FirstCellHeight Then
>LabelString = Mid(Format(LabelValue), 2)
>oCell.Range.InsertBefore LabelString
>LabelValue = LabelValue + 1
>End If
>Next oCell
>Next oTable

>End Sub



Thu, 21 Aug 2003 04:43:23 GMT  
 Creating Sequential Numbering in Labels
From the File menu, choose page Setup.
On the Layout tab, add a checkmark to different First page
Quote:

> Hi Bill,

> Thanks for the code. Have not had time to check it out yet, but I am
> sure it will work.

> The labels I am using do have spacer cells...

> Now to a slighty different topic, I have created a template for a
> legal statement. I have put a header on the first page, but if the
> doucment ends up going to 2 pages or more, I don't want any header.

> I know how to manually fix this by creating a section break, and
> making the header so its not the 'same as previous'.

> But how would you set this up with a template.?

> Cheers

> - Al

> On Fri, 2 Mar 2001 19:44:22 -0600, "Bill Coan [Word MVP]"

> >Hi Al,

> >The following code will add a number at the start of each label, beginning
> >with 00001 and incrementing this value for each succeeding label.

> >To change the starting value or the number of digits, tweak these items in
> >the code. Warning! The number of digits should be kept below 10.

> >The code isn't too hard to follow. I haven't commented it but you can always
> >post back for help if you need some. The code relies on the fact (I think
> >it's a fact) that the first cell in each table represents an actual label,
> >whereas other cells in the table, if sized differently from the first cell,
> >do NOT represent labels but just spacers.

> >Here ya go:

> >Sub NumberTheLabels()
> >Dim oTable As Table
> >Dim oCell As Cell
> >Dim StartAt As Long
> >Dim NumberOfDigits As Integer
> >Dim LabelString As String
> >Dim LabelValue As Long
> >Dim LoopCounter As Integer
> >Dim FirstCellWidth As Long
> >Dim FirstCellHeight As Long

> >StartAt = 1
> >NumberOfDigits = 5

> >LabelValue = 1
> >For LoopCounter = 1 To NumberOfDigits
> >LabelValue = LabelValue * 10
> >Next LoopCounter

> >LabelValue = LabelValue + StartAt

> >If ActiveDocument.Tables.Count = 0 Then
> >MsgBox "Couldn't find any labels"
> >End If

> >For Each oTable In ActiveDocument.Tables
> >FirstCellWidth = oTable.Range.Cells(1).Width
> >FirstCellHeight = oTable.Range.Cells(1).Height
> >For Each oCell In oTable.Range.Cells
> >If oCell.Width = FirstCellWidth _
> >And oCell.Height = FirstCellHeight Then
> >LabelString = Mid(Format(LabelValue), 2)
> >oCell.Range.InsertBefore LabelString
> >LabelValue = LabelValue + 1
> >End If
> >Next oCell
> >Next oTable

> >End Sub



Thu, 21 Aug 2003 04:59:32 GMT  
 Creating Sequential Numbering in Labels
Set up a one-page template so that, when it expands to two or more pages,
the new pages will have different headers and footers than the first page.

Solution:
1. Open template and view the header and footer.
2. Put material into the header and footer. Make sure this is the material
that you want to appear on pages 2 through X.
3. Click the Page Setup tool on the Headers and Footers toolbar, then click
the Layout tab and select Different First Page and click OK.
4. Put in the material you want to appear on page one.
5. Save and close the template.
From now on, when documents based on this template grow to two or more
pages, the header and footer on pages 2-X will display the material you
entered in Step 2.

Bill Coan
Fill out letters, contracts, forms, in seconds! DataPrompter
prompts you for data, inserts it, updates it automatically.
Details at http://www.wordsite.com/DataPrompter.html

Quote:




Quote:
> Hi Bill,

> Thanks for the code. Have not had time to check it out yet, but I am
> sure it will work.

> The labels I am using do have spacer cells...

> Now to a slighty different topic, I have created a template for a
> legal statement. I have put a header on the first page, but if the
> doucment ends up going to 2 pages or more, I don't want any header.

> I know how to manually fix this by creating a section break, and
> making the header so its not the 'same as previous'.

> But how would you set this up with a template.?

> Cheers

> - Al

> On Fri, 2 Mar 2001 19:44:22 -0600, "Bill Coan [Word MVP]"

> >Hi Al,

> >The following code will add a number at the start of each label,
beginning
> >with 00001 and incrementing this value for each succeeding label.

> >To change the starting value or the number of digits, tweak these items
in
> >the code. Warning! The number of digits should be kept below 10.

> >The code isn't too hard to follow. I haven't commented it but you can
always
> >post back for help if you need some. The code relies on the fact (I think
> >it's a fact) that the first cell in each table represents an actual
label,
> >whereas other cells in the table, if sized differently from the first
cell,
> >do NOT represent labels but just spacers.

> >Here ya go:

> >Sub NumberTheLabels()
> >Dim oTable As Table
> >Dim oCell As Cell
> >Dim StartAt As Long
> >Dim NumberOfDigits As Integer
> >Dim LabelString As String
> >Dim LabelValue As Long
> >Dim LoopCounter As Integer
> >Dim FirstCellWidth As Long
> >Dim FirstCellHeight As Long

> >StartAt = 1
> >NumberOfDigits = 5

> >LabelValue = 1
> >For LoopCounter = 1 To NumberOfDigits
> >LabelValue = LabelValue * 10
> >Next LoopCounter

> >LabelValue = LabelValue + StartAt

> >If ActiveDocument.Tables.Count = 0 Then
> >MsgBox "Couldn't find any labels"
> >End If

> >For Each oTable In ActiveDocument.Tables
> >FirstCellWidth = oTable.Range.Cells(1).Width
> >FirstCellHeight = oTable.Range.Cells(1).Height
> >For Each oCell In oTable.Range.Cells
> >If oCell.Width = FirstCellWidth _
> >And oCell.Height = FirstCellHeight Then
> >LabelString = Mid(Format(LabelValue), 2)
> >oCell.Range.InsertBefore LabelString
> >LabelValue = LabelValue + 1
> >End If
> >Next oCell
> >Next oTable

> >End Sub



Thu, 21 Aug 2003 11:27:43 GMT  
 Creating Sequential Numbering in Labels

Quote:

> Hi Folks,

> I am printing A4 labels and want to add some sequntial numering.

> For instance

> 01/102/G01 - G20

> I have created a doucment of Avery L7160 labels, whats the easiest way
> to add the numbering? I assume a simple bit of code can do it, but
> could somebody help me out please?

If you've created a MailingLabel object where every mailing label is
identical, there is no property to insert sequential numbering: all the
labels are the same. I guess you could use the SingleLabel property with a
separate CreateNewDocument method for each label within a loop, going across
the rows or else down the columns one by one, and for each new iteration of
the single label, change the text to include an incrementing number as part
of the text. That should work, if tedious. The other way would be to make  a
data source document which consisted of the same label address over and
over, make a MailMerge document to merge the document and use AddMergeRec
Method to add a MergeRec field, which will do this for you.

--
Paul Berkowitz



Sun, 24 Aug 2003 16:30:24 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Sequential numbers in labels

2. Create a sequential stock number ???

3. macro to create specified number of labels

4. How to create a certain number of buttons / labels

5. Adding a sequential date count number to an imported table

6. Get records if sequential numbers are found

7. Sequential Numbering in Query

8. Sequential Numbering

9. How to generate a sequential number for each new form

10. generating a unique (sequential) number to subject line

11. massaging the format of sequential numbers

12. Printing Sequential Page Numbers

 

 
Powered by phpBB® Forum Software