Thanks Anand...here is the code:
Private Sub cmdAddTargetItem_Click()
'This sub procedure inserts a new row into the Target Item table. The
procedure unlocks
'the document, makes the change, then locks it again
'unlock document if protected
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
End If
Selection.GoTo What:=wdGoToBookmark, Name:="P4"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk 'wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InsertRows 1
Selection.Collapse Direction:=wdCollapseStart
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
'lock document if unprotected
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:="password"
End If
End Sub
'----------------------------------------------------------------------------------------------------
Private Sub cmdAddDragItem_Click()
'This sub procedure inserts a new row into the Drag Item table. The
procedure unlocks
'the document, makes the change, then locks it again
'unlock document if protected
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
End If
Selection.GoTo What:=wdGoToBookmark, Name:="P6"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InsertRows 1
Selection.Collapse Direction:=wdCollapseStart
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
'lock document if unprotected
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:="password"
End If
End Sub
When the first sub procedure cmdAddTargetItem_Click() is run, it changes the
name of the command button cmdAddDragItem by adding a "1" to the end of its
name, for example, from cmdAddDragItem to cmdAddDragItem1.
Each time the procedure runs it appends another 1.
I hope this helps.
David