dj44
02-25-2018, 07:43 AM
Good day folks,
I wanted to understand some logic about array terms
It’s a bit back wards but I wanted to see how to do this
Now if the Replace term = "SKIP" completely skip the search term and its execution
Sub Skip_Array_Terms()
Dim oRng As Word.Range
Dim arrWords As Variant
Dim oReplace As Variant
Dim i As Long, j As Long
arrWords = Array("A", "B", "C", "D")
oReplace = Array("Apple", "SKIP", "Cat", "SKIP")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
j = 0
With oRng.Find
Do While .Execute(FindText:=arrWords(i), MatchWholeWord:=True)
'IF oReplace(i)="SKIP" << something like this?
oRng = oReplace(i)
oRng.Collapse 0
Loop
End With
Next i
Set oRng = Nothing
End Sub
What are the ways I may be able to achieve something like this, if it’s the same word then it is easier a clause somehwere?
I dont know if i would need to split the array as its the same word on the replace i would like to skip
I wanted to understand some logic about array terms
It’s a bit back wards but I wanted to see how to do this
Now if the Replace term = "SKIP" completely skip the search term and its execution
Sub Skip_Array_Terms()
Dim oRng As Word.Range
Dim arrWords As Variant
Dim oReplace As Variant
Dim i As Long, j As Long
arrWords = Array("A", "B", "C", "D")
oReplace = Array("Apple", "SKIP", "Cat", "SKIP")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
j = 0
With oRng.Find
Do While .Execute(FindText:=arrWords(i), MatchWholeWord:=True)
'IF oReplace(i)="SKIP" << something like this?
oRng = oReplace(i)
oRng.Collapse 0
Loop
End With
Next i
Set oRng = Nothing
End Sub
What are the ways I may be able to achieve something like this, if it’s the same word then it is easier a clause somehwere?
I dont know if i would need to split the array as its the same word on the replace i would like to skip