Bookmark content: either 480 or 230
Bookmark Name: Voltage
Ref Voltage
Also, below is my macro. I've a feeling it is a timing issue, but am not
sure how to fix it.
Sub AutoOpen()
' Serialize Macro
' Macro recorded 06/12/2009 by Bryan Daniels
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range, SerialNumber As Long, Counter As Long, Config As String,
PPONumber As Long
Dim ULLabelPrefix As String, ULLabel As Long, Voltage As String
' 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 for PPO Number.
NumCopies = Val(InputBox(Message, Title, Default))
If NumCopies = Cancel Then End
Message = "Enter the PPO Number"
Title = "PPO Number"
PPONumber = Val(InputBox(Message, Title, ""))
' Display message, title, and default value for Serial Number.
Message = "Enter the starting Serial Number"
Title = "Serial Number"
SerialNumber = Val(InputBox(Message, Title, ""))
' Display message, title, and default value for UL Label Prefix.
Message = "Enter the UL Label Prefix (2 Letters)"
Title = "UL Label Prefix"
ULLabelPrefix = InputBox(Message, Title, "")
' Display message, title, and default value for UL Label.
Message = "Enter the starting UL Label number (NUMBERS ONLY!)"
Title = "UL Label"
ULLabel = Val(InputBox(Message, Title, ""))
' Display message, title, and default value for configuration.
Message = "Enter the configuration number."
Title = "Configuration Number"
Config = InputBox(Message, Title, "")
' Display message, title, and default value for Voltage.
Message = "Enter the line Voltage."
Title = "Line Voltage"
Voltage = Val(InputBox(Message, Title, ""))
Documents("MPL99910014.doc").Activate
ActiveDocument.Fields.Update
Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0
Set Rng2 = ActiveDocument.Bookmarks("Config").Range
Set Rng3 = ActiveDocument.Bookmarks("PPONumber").Range
Set Rng4 = ActiveDocument.Bookmarks("ULLabel").Range
Counter = 0
Set Rng5 = ActiveDocument.Bookmarks("ULLabelPrefix").Range
Set Rng6 = ActiveDocument.Bookmarks("Voltage").Range
ActiveDocument.Fields.Update
While Counter < NumCopies
Rng1.Delete
Rng2.Delete
Rng3.Delete
Rng4.Delete
Rng5.Delete
Rng6.Delete
Rng1.Text = Format(SerialNumber, "00000000")
Rng2.Text = Config
Rng3.Text = PPONumber
Rng4.Text = Format(ULLabel, "000000")
Rng5.Text = Format(ULLabelPrefix, ">")
Rng6.Text = Voltage
ActiveDocument.Fields.Update
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
ULLabel = ULLabel + 1
Counter = Counter + 1
Wend
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
..Add Name:="SerialNumber", Range:=Rng1
..Add Name:="Config", Range:=Rng2
..Add Name:="PPONumber", Range:=Rng3
..Add Name:="ULLabel", Range:=Rng4
..Add Name:="ULLabelPrefix", Range:=Rng5
..Add Name:="Voltage", Range:=Rng6
End With
'Next line added to update { REF SerialNumber }
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
If Fld.Type = wdFieldRef Then Fld.Update
Next
End Sub
Thx, Bryan