Consulting

Results 1 to 3 of 3

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

  1. #1

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

    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.
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi Zrob,

    You could use code like:
    [vba]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[/vba]
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    That worked nicely, thanks for the help!
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •