Results 1 to 3 of 3

Thread: OLE Word Objects

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    1

    OLE Word Objects

    I am just stating with OLE, and I’m weak on objects. First a bit of background, then questions.

    My first two OLE attempts have had some success.

    My first attempt was to control MS Word 95 with my VB6 on WMe. It turns out that I can’t use MS Word 95 this way as it does not exist in the VB’s references, so using code like:

    Public objApp as New Word.application
    Public objDoc as Object

    does not work -- the Word.appliation does not exist, so code like
    objapp.visible=true
    and
    objdoc.content = "My first OLE"
    does not work.

    For attempt two, I duplicated a little program from "How to use the Spelling Corrector tool of MS Word within VB" on the VBWorld site http://216.26.168.92/tips/tip81.html (nice and simple). It works with older MS Words. The sequence of operations:

    Create Word Object { Set Word = CreateObject("Word.Basic") }
    Show Word
    Word New file
    Insert text into Word from VB text box
    Start Word Spell checker
    Word Edit Select All
    Then grab the selection and put in into a VB text box.

    Almost works. It works if I take out the call to the spell checker. The spell checker creates an error 51 which just says the spell checker is done. On Error Resume Next does not help -- although the code runs, nothing is output after starting the spell checker. I’m sure the whole problem is my trying to use the old Word95, but it is what I have.

    QUESTIONS:
    1) Is there a way I can deal with the error caused by the spell checker indicating it is done, so I can use the spell checker?

    2) Whereas the {Public objApp as New Word.application} is exposed when I choose the appropriate newer MS Word reference in VB, where do I find out about the {CreateObject("Word.Basic")}? Where did the "Word.Basic" come from? Where do I find out about it and others like it?

    3) What is the difference between the two word objects created in the two examples {Public .... word.application vs. Set .... CreateObject("Word.Basic") }?

    I realize the answers to the everything afte the first question could be multiple tutorials, but I'm just looking for a hint here, so I can better focus my search. (A tutorial would be good too!)

    Thanks.
    -Mike-

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898
    Hi,

    Dont know all the answers but....
    When you use dim word as new word.application, this makes the object early bound (So after you compile the code the application knows about the object and so should run a little faster, it will also run in the same process space as the parent app). Using CreateObject makes it late bound. The compiled app doesn't know about the object until the createobject is hit in code, making it a little slower, however it will use it's own process space.

    Word 95 has a totally different structure to word97 and 2000, the command are different. If you start looking at references to word2000 for example dont be surprised if they dont work in 95.

    A neat trick is to create a macro within word, then cut and paste it into VB it normally only requires a few tweeks to then get it to work.

    Regards
    Will

  3. #3
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    I'm also new to the OLE game. I am trying to migrate an older application which has Word.Basic cmds through out. Where can I find the newer Word. Application type eqivalents? The more common cmds I've been able to find, but now I'm stuck trying to replace cmds like "objWord.EditGoTo" or "objWord.InsertPageBreak" etc.

    Any suggestions or help?

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