PDA

View Full Version : Solved: Looking for vba advice on how to read in word data to a string?



Zrob
10-19-2010, 05:19 PM
I have a word doc that is kinda used like a invoice, its does not contain paragraph style text, instead it just has a few simple text box's that contain some text. Kinda like a title block on a blue print ....... how would I go about creating a vba sub that would say read in all text from the active document since it will be open, the user would already have it open.

Thanks for any advice.

macropod
10-19-2010, 11:27 PM
Hi Zrob,

You could use code like:
Sub Get_Text()
Dim oRng As Range, strTxt As String
For Each oRng In ActiveDocument.StoryRanges
Do
strTxt = strTxt & oRng.Text & vbCrLf
Set oRng = oRng.NextStoryRange
Loop Until oRng Is Nothing
Next
MsgBox strTxt
End Sub

Zrob
10-20-2010, 03:18 PM
That worked nicely, thanks for the help!