J
JulieJinky via OfficeKB.com
Hi all,
This piece of my macro (not pretty, I know) works exactly the way I want it
to...
However when I add the commented out lines, the lower part (the For Loop) of
the code does not seem to execute... I cannot figure out why...
Any help would be greatly appreciated...
Dim strPatrol As String
Dim i As Integer
If optPatrolOne = True Then strPatrol = "Patrol One"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="71"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="71"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="72"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="71"
If optPatrolTwo = True Then strPatrol = "Patrol Two"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="64"
If optPatrolThree = True Then strPatrol = "Patrol Three"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="80"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = strPatrol
.Replacement.Text = ""
.Forward = True
End With
Selection.Find.Execute
Application.ScreenUpdating = False
For i = 1 To 8
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Next i
frmPatrolChoice.Hide
Application.ScreenUpdating = True
Selection.HomeKey Unit:=wdStory
This piece of my macro (not pretty, I know) works exactly the way I want it
to...
However when I add the commented out lines, the lower part (the For Loop) of
the code does not seem to execute... I cannot figure out why...
Any help would be greatly appreciated...
Dim strPatrol As String
Dim i As Integer
If optPatrolOne = True Then strPatrol = "Patrol One"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="71"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="71"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="72"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="71"
If optPatrolTwo = True Then strPatrol = "Patrol Two"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="64"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="64"
If optPatrolThree = True Then strPatrol = "Patrol Three"
'ActiveDocument.Tables(4).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(7).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(10).Cell(2, 4).Select
'Selection.TypeText Text:="80"
'ActiveDocument.Tables(13).Cell(2, 4).Select
'Selection.TypeText Text:="80"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = strPatrol
.Replacement.Text = ""
.Forward = True
End With
Selection.Find.Execute
Application.ScreenUpdating = False
For i = 1 To 8
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Next i
frmPatrolChoice.Hide
Application.ScreenUpdating = True
Selection.HomeKey Unit:=wdStory