Peskarik
02-19-2008, 10:51 AM
:think:
Hello, everybody
I have an open Word document where I have written a sentence.
Now I want to display a message box with each word in a sentence.
Easy way:
Sub MyWords()
For Each oWord in ThisDocument.Words
MsgBox oWord.Text
Next
End Sub
But why does not the following work? :(
Sub DisplayWords()
Dim i As Integer
Dim myWords()
ReDim myWords(ThisDocument.Words.Count)
myWords = ThisDocument.Words
For i = 1 To UBound(myWords)
MsgBox myWords(i).Text
Next
End Sub
I have problems understanding what exactly I am assigning to the array myWords.:dunno
Please, explain what is wrong with this code? :mkay
Hello, everybody
I have an open Word document where I have written a sentence.
Now I want to display a message box with each word in a sentence.
Easy way:
Sub MyWords()
For Each oWord in ThisDocument.Words
MsgBox oWord.Text
Next
End Sub
But why does not the following work? :(
Sub DisplayWords()
Dim i As Integer
Dim myWords()
ReDim myWords(ThisDocument.Words.Count)
myWords = ThisDocument.Words
For i = 1 To UBound(myWords)
MsgBox myWords(i).Text
Next
End Sub
I have problems understanding what exactly I am assigning to the array myWords.:dunno
Please, explain what is wrong with this code? :mkay