Results 1 to 4 of 4

Thread: Opening Word Documents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Somerset, UK
    Posts
    93

    Question

    Anybody know how to open a word document, find & replace, then save (in same format) from vb5>???

  2. #2
    Member
    Join Date
    Jun 2000
    Posts
    63
    You need to add the Microsoft Word object library as a reference to your project.
    to envoke an instance of Word:

    dim wdApp as Word.Application
    dim wdDoc as Word.Document

    set wdApp = New Word.Application
    set wdApp = New Word.Document

    You can then control word via your VB app in a similar manner to that of macro-generated code. If you wish to to a find and replace type of command, record a macro to do it, examine the code, and this can be used (more or less) within your defined app/doc objects.

    When your done, make sure vb does a

    wdDoc.Close
    wdApp.Quit

    to close word down poperly.

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    84
    Take a look at this vb-world article

    http://www.vb-world.net/articles/wordreports/index.html

    hope this helps!

  4. #4
    Member
    Join Date
    Jun 2000
    Posts
    63

    correction to my original post

    I meant to say:

    set wdApp=New Word.Application
    set wdDoc=wdApp.Documents.Add

    just testing......

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