• vb application to word document

    Author
    Topic
    #1769084

    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

    Viewing 1 reply thread
    Author
    Replies
    • #1782097

      yikes

      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
      http://msdn.microsoft.com/library/techart/msdn_wbmigrat.htm

      And this link talks about automating office…
      http://support.microsoft.com/support/kb/ar…s/Q253/2/35.ASP

      2cents

    • #1782105

      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.

    Viewing 1 reply thread
    Reply To: vb application to word document

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: