C
Code Numpty
I use the following macro in Word 2003 to produce sequentially numbered
certificates & have 2 problems with it.
Sub SEQserialnumber()
'
' SEQserialnumber Macro
' Macro created 11/09/2007 by Sharon
'
Dim Counter As Long
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. Get
it right you can't stop it!"
' Set title.
Title = "Print"
' Set default.
Default = "1"
' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
' Edit from Jay Freedman to enable user to specify serial number
Message = "Enter the starting serial number"
Title = "Serial Number"
SerialNumber = Val(InputBox(Message, Title, Default))
'Next line added to cause Ask field to fire pop-ups
ActiveDocument.Fields.Update
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
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With
'Next line added to update { REF SerialNumber }
'This is more selective than just updating all the fields; in
'particular, the Ask fields (which have .Type = wdFieldAsk) won't be
'updated the second time.
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
If Fld.Type = wdFieldRef Then Fld.Update
Next
ActiveDocument.Close SaveChanges:=False
End Sub
Problem 1: I know find out that serial numbers begin with zeroes e.g.
0000001 to 0000005. If zeroes are entered they do not print and they must do
so to much pre-printed labels.
Problem 2: The 2nd serial number instance is not printing. This is a
mergefield in the document as below.
{ REF SerialNumber \*MERGEFORMAT }
I would be truly grateful for some help with both of these, thanks.
certificates & have 2 problems with it.
Sub SEQserialnumber()
'
' SEQserialnumber Macro
' Macro created 11/09/2007 by Sharon
'
Dim Counter As Long
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. Get
it right you can't stop it!"
' Set title.
Title = "Print"
' Set default.
Default = "1"
' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
' Edit from Jay Freedman to enable user to specify serial number
Message = "Enter the starting serial number"
Title = "Serial Number"
SerialNumber = Val(InputBox(Message, Title, Default))
'Next line added to cause Ask field to fire pop-ups
ActiveDocument.Fields.Update
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
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With
'Next line added to update { REF SerialNumber }
'This is more selective than just updating all the fields; in
'particular, the Ask fields (which have .Type = wdFieldAsk) won't be
'updated the second time.
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
If Fld.Type = wdFieldRef Then Fld.Update
Next
ActiveDocument.Close SaveChanges:=False
End Sub
Problem 1: I know find out that serial numbers begin with zeroes e.g.
0000001 to 0000005. If zeroes are entered they do not print and they must do
so to much pre-printed labels.
Problem 2: The 2nd serial number instance is not printing. This is a
mergefield in the document as below.
{ REF SerialNumber \*MERGEFORMAT }
I would be truly grateful for some help with both of these, thanks.