Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assigning variable text of a word doc

Status
Not open for further replies.

tylerjones

Programmer
Jan 4, 2002
10
US
I haven't worked much with VBA, mainly just VB and COM and I need to assign the text in a word doc to a variable. Does anyone know how I can do it without saving the doc as a text file, opening it with the file system object and readall the text into a variable. That seems like more work than needs to be done for this but it's the only way I've figured out to do this. Thanks.
 
you could try something like...

Code:
Dim oDoc As Object
Dim sText As String

Set oDoc = GetObject("C:\My Documents\test.doc", "Word.Document")

sText = oDoc.Range.Text

Set oDoc = Nothing

MsgBox sText
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top