I'm trying to replace every 10th word in a Word document with underscores equal to the length of the word. This is the code that I've tried so far but it doesn't seem close to working. I'm new to VBA. I feel like I'm able to move between words using the FOR EACH loop but I'm having trouble working the selection object
Sub Macro1()
'
' Macro1 Macro
'
'
i = 0
For Each aword In ActiveDocument.Words
' Selection = aword
i = i + 1
aword.Select
If (i Mod 10) = 0 Then
blanks = ""
For Counter = 0 To Len(aword)
blanks = blanks + "_"
Next Counter
Word.Selection.TypeText (blanks)
aword.Cut
End If
Next aword
End Sub
Also, is VBA the easiest language available for doing something like this in a word processing document? Is there a simpler one? I'm trying to help a student who last coded with Wang VS Glossary Decision Processing language https://en.wikipedia.org/wiki/Wang_Laboratories#Wang_OIS