C
Code Numpty
In Word 2003 I have a template with 2 ASK fields and a macro which fires the
pop-ups.
When the data is entered in the pop-ups is it possible to program it so that
the enter key can be used as well as clicking the OK button?
Macro as follows:
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
pop-ups.
When the data is entered in the pop-ups is it possible to program it so that
the enter key can be used as well as clicking the OK button?
Macro as follows:
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