Results 1 to 3 of 3

Thread: Word Automation

  1. #1

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Word Automation

    Hey,

    How can I get the content of a word document into a string variable?

    Thanks,
    Don't anthropomorphize computers -- they hate it

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Word Automation

    VB Code:
    1. Dim oWord As Word.Application, oDoc As Word.Document, sText As String
    2.    
    3.     Set oWord = New Word.Application
    4.     Set oDoc = oWord.Documents.Open("D:\Test.doc")
    5.    
    6.     sText = oDoc.Range(oDoc.Range.Start, oDoc.Range.End).Text
    7.     Debug.Print sText
    8.    
    9.     oDoc.Close
    10.     oWord.Quit
    11.     Set oDoc = Nothing
    12.     Set oWord = Nothing

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Word Automation

    probably a better way but

    ActiveDocument.Select
    AllText = Selection.Text
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

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



Click Here to Expand Forum to Full Width