Reading from word file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shyDeveloper
    New Member
    • Feb 2008
    • 2

    Reading from word file

    Hi,

    I need to read from word document using visual basic 6 and then process the data accordingly.

    Your help appricaiated.

    ReGards
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by shyDeveloper
    Hi,

    I need to read from word document using visual basic 6 and then process the data accordingly.

    Your help appricaiated.

    ReGards
    Create an object with the word document:

    [CODE=vb]dim obj1 as object
    set obj1=createobje ct("word.applic ation")
    obj1.documents. open ("c:\myDoc.doc" )
    obj1.visible = true 'this is not necesary, you can work with the document while is not visible.[/CODE]

    And then for working with the document, check the syntaxis that apply to a word document. You can check them in the object browser of your Words VBA (F2), or just record a macro and use its code inside a With Obj1.ActiveDocu ment , or something like that.

    Have in mind that the macro recorder will use many Word's constants that VB6 wont recognize, change them for its numeric value (which can be checked in the object browser too, or in the debuging mode of the macro by passing the mouse over the constant)

    Comment

    • shyDeveloper
      New Member
      • Feb 2008
      • 2

      #3
      Thanks for your reply.
      You must think I am lazy which I am not I am just shy :).

      Can you give me any source code which read from word document witout any macro.

      I am realy stuck at this point I have to add this word document text in html template.


      Regards,


      Originally posted by kadghar
      Create an object with the word document:

      [CODE=vb]dim obj1 as object
      set obj1=createobje ct("word.applic ation")
      obj1.documents. open ("c:\myDoc.doc" )
      obj1.visible = true 'this is not necesary, you can work with the document while is not visible.[/CODE]

      And then for working with the document, check the syntaxis that apply to a word document. You can check them in the object browser of your Words VBA (F2), or just record a macro and use its code inside a With Obj1.ActiveDocu ment , or something like that.

      Have in mind that the macro recorder will use many Word's constants that VB6 wont recognize, change them for its numeric value (which can be checked in the object browser too, or in the debuging mode of the macro by passing the mouse over the constant)

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by shyDeveloper
        Thanks for your reply.
        You must think I am lazy which I am not I am just shy :).

        Can you give me any source code which read from word document witout any macro.

        I am realy stuck at this point I have to add this word document text in html template.


        Regards,
        You dont need any macro, the same vb code used in Word VBA is good for VB6, just be careful with the constants... e.g.

        in the macro you should write:
        documents.open ("c:\document.d oc")

        once you've created the object in VB6, you should write
        obj1.documents. open ("c:\document.d oc")
        in VB6

        the same for almost everything.

        HTH

        Comment

        Working...