Results 1 to 3 of 3
  1. #1

    vb application to word document

    I started with a simple word document with text and text boxes on it. I then wrote a vb application to store each record in a access database.I would like to press a command button on the vb application open the(saved word document with empty textboxes) and send the information to the document's text boxes so I can print. Can this be done and if so would you point me in the right direction. I would like to do this so I do not have to reproduce this document (it is large and needs to be in a specific format). Using VB6 and Windows 98 word2000 User will be using w/95 and word 97 and will not have access2000 Just the Database. Thanks

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Thanked 0 Times in 0 Posts

    Re: vb application to word document

    <img src=/S/yikes.gif border=0 alt=yikes width=15 height=15>

    One of my fellow programmers says when users ask "Can this or that be done?", "Anything can be done given enough time."

    Yes, I think it can be done. The hardest part would be automating Word 95. Word 95 uses WordBasic as it's programming language and Word 97 & Word 2000 use VBA. Word 97 & Word 2000 can translate Word 95's WordBasic with various degrees of success.

    Here's a couple of articles from Microsoft

    This link talks about WordBasic
    <A target="_blank" HREF=></A>

    And this link talks about automating office...
    <A target="_blank" HREF=></A>

    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    L.A., California
    Thanked 0 Times in 0 Posts

    Re: vb application to word document

    I'm doing something like that, here's how I did it:

    The vb app needs a reference to the Microsoft Word 8.0 Object Library.

    Dim out application and document objects:
    Dim WordApp as Application
    Dim MyDoc as Document

    Create instances of these objects:
    Set WordApp = GetObject(, "Word.Application")
    Set MyDoc = WordApp.Documents.Open("C:My Documentsxxx.doc"). Or, if the document is already open:
    Set MyDoc = WordApp.ActiveDocument

    Note: the GetObject command assumes Word is already opened. If not opened, you have to use CreateObject instead. I'm not sure what the first parameter was for, you'll have to search the help on that.

    Anyway, once this works, you can have access to all of Word's functionality, such as referencing the bookmarks collection, etc., just like from Word VBA.

    Slight complication: In Word VBA, you can refer to things such as the application object, the selection object, etc. From VB, you need to be a little more specific. If referring to a Selection, you need to prefix it with the name of the application object: Instead of saying something like "Selection.Range..." you need to say "WordApp.Selection.Range...", etc. Anytime you would refer to ActiveDocument in Word VBA, you can refer to MyDoc, the earlier created object.

    Hope this helps. Feel free to e-mail questions.

Posting Permissions

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