An implementation of Visual Basic that is built into Microsoft products.
Hello @Edward Evans ,
You can use a Range to locate a word and calculate its position in the document by counting the words before that range. Word VBA does not provide a direct built-in property for the word’s index in the Words collection, so it usually has to be derived.
This is a minimal sample from my side:
Sub NoteCurrentVocabularyWord()
Dim doc As Document
Dim vocabRange As Range
Dim tempRange As Range
Dim wordIndex As Long
Set doc = ActiveDocument
Set vocabRange = Selection.Range
vocabRange.Expand wdWord
Set tempRange = doc.Range(Start:=0, End:=vocabRange.Start)
wordIndex = tempRange.Words.Count + 1
MsgBox "Vocabulary word: " & Trim(vocabRange.Text) & vbCrLf & _
"Start position: " & vocabRange.Start & vbCrLf & _
"Word index: " & wordIndex
End Sub
To test it, click inside a word in Word and run the macro. It will show the word, its start position, and its calculated index. If your main goal is to keep vocabulary in document order, using Range.Start is often the more reliable method.
Hope this clarifies your question. If you found my answer helpful, thank you much for following this guide to give feedback.
Thank you.