Does anyone know how to loop through all of the textboxes in a word document and output the text they contain.
I have tried the following code but can not get it to work. I keep getting a TypeMismatchException error on the msgbox.
It doesn't help that the IDE does not show the TextFrame or the HasText after you have entered the period, followed by tab. Is this something missing in the IDE or am I doing something wrong?
Dim word as New WordApplication
Dim doc as WordDocument
Dim f As FolderItem
f = GetOpenFolderItem(FileTypes.ApplicationMsword)
If f Is Nil Then
if word is Nil then
MsgBox "Word failed to open"
doc = word.Documents.Open(f.AbsolutePath)
word.Visible = True
for i as integer = 1 to word.ActiveDocument.Shapes.Count
if word.ActiveDocument.Shapes(i).TextFrame.HasText then
In case anyone is interested. I needed to add the .Text to the end of the TextRange.
Can't seem to get to the msdn.microsoft.com website today so had to google loads to try and find the answer.