B
Bryan
I am not sure why, but my bookmark only returns the first 2 characters. I
enter 30V23 in the line and it only shows the 30. Included is my macro if
someone knows why this happens! The bookmark is Config. TIA, Bryan
Sub AutoOpen()
' Serialize Macro
' Macro recorded 06/11/2009 by Bryan
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
' 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 configuration.
Message = "Enter the configuration number."
Title = "Configuration Number"
Config = 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, ""))
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
While Counter < NumCopies
Rng1.Delete
Rng2.Delete
Rng3.Delete
Rng4.Delete
Rng5.Delete
Rng1.Text = Format(SerialNumber, "00000000")
Rng2.Text = Config
Rng3.Text = PPONumber
Rng4.Text = Format(ULLabel, "000000")
Rng5.Text = Format(ULLabelPrefix, ">")
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
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
enter 30V23 in the line and it only shows the 30. Included is my macro if
someone knows why this happens! The bookmark is Config. TIA, Bryan
Sub AutoOpen()
' Serialize Macro
' Macro recorded 06/11/2009 by Bryan
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
' 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 configuration.
Message = "Enter the configuration number."
Title = "Configuration Number"
Config = 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, ""))
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
While Counter < NumCopies
Rng1.Delete
Rng2.Delete
Rng3.Delete
Rng4.Delete
Rng5.Delete
Rng1.Text = Format(SerialNumber, "00000000")
Rng2.Text = Config
Rng3.Text = PPONumber
Rng4.Text = Format(ULLabel, "000000")
Rng5.Text = Format(ULLabelPrefix, ">")
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
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