Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Aug 11, 2020 10:53 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [Solved]Reading the contents of a textbox in a Word document
PostPosted: Tue Feb 19, 2013 10:05 am 

Joined: Wed Aug 15, 2012 1:49 am
Posts: 7

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
End If

if word is Nil then
MsgBox "Word failed to open"
end if

doc = word.Documents.Open(f.AbsolutePath)
word.Visible = True


msgbox word.ActiveDocument.Shapes.Count

for i as integer = 1 to word.ActiveDocument.Shapes.Count
if word.ActiveDocument.Shapes(i).TextFrame.HasText then
msgbox word.ActiveDocument.Shapes(i).TextFrame.TextRange.Text
end if


In case anyone is interested. I needed to add the .Text to the end of the TextRange.
Can't seem to get to the website today so had to google loads to try and find the answer.



Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group