Results 1 to 14 of 14

Thread: Resolved ***** MSWord Dictionary

  1. #1

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Resolved ***** MSWord Dictionary

    In an effort to learn (alot) more VB, I am thinking of making a
    small dictionary utility.

    My question is, can you 'tap' into the MSWord dictionary
    without running the MSWord App?
    I'm also open to suggestions

    Cheers,
    Bruce.
    ________
    Hot_Zouvineir
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:58 AM.

  2. #2

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Ooops

    Sorry, I also ment to say, if opening MSWord was the only way
    to go, can it be done in the background.

    The idea being a simple form, with a text box containg the
    search string, and a results/suggestion list.


    Bruce.
    ________
    HERBALAIRE VAPORIZER
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:58 AM.

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    In word, you can do it like this:

    VB Code:
    1. Dim wdApp As New Word
    2. Set sugList = wdApp.GetSpellingSuggestions("homicydal")
    3.  
    4. If sugList.Count = 0 Then
    5.     MsgBox "No suggestions were found"
    6. Else
    7.     For Each sug In sugList
    8.         MsgBox sug.Name
    9.     Next sug
    10. End If

    Something like that

  4. #4

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Word?

    Sorry Dave, Forgive my ignorance
    Does your example go in VB or Word?

    Cheers
    Bruce.

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Word, What version of word do you have?

    You can put that into VB with a few modifications

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    1. In visual basic, click Project (menu) then References,
    2. Add a reference to Microsoft Word 9.0 Object Library
    3. Add a textbox called txtStr to your VB form
    3. Add a listbox called lstSug to your VB form
    4. Add the following code to your VB form

    VB Code:
    1. Dim wdApp As New Word.Application
    2. Dim wdDoc As Word.Document
    3. Private Sub Form_Load()
    4. Set wdDoc = wdApp.Documents.Add
    5. txtStr = ""
    6. End Sub
    7. Private Sub Form_Unload(Cancel As Integer)
    8. 'Clean up
    9. Set wdDoc = Nothing
    10. Set wdApp = Nothing
    11. End Sub
    12. Private Sub txtStr_Change()
    13. lstSug.Clear
    14. Set sugList = wdApp.GetSpellingSuggestions(txtStr) 'Get the suggestions
    15. If sugList.Count = 0 Then
    16.     lstSug.AddItem "No suggestions were found"
    17. Else
    18.     For Each sug In sugList
    19.         lstSug.AddItem sug.Name
    20.     Next sug
    21. End If
    22. End Sub

    It will find suggestions for all new input in the textbox

  7. #7

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Thanks Dave

    Ahhh,

    Things are alot clearer now! Cheers.

    I have Office 97.

    What I can't seem to find is the Microsoft Word 9.0 Object Library
    reference. It's not in my list.

    Bruce.
    ________
    California Medical Marijuana Dispensaries
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:59 AM.

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Then go down a version...

    Maybe Word 8.0 Object Library?

  9. #9

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Thanks Again

    That did it.

    I must be blind, I didn't even see the reference to Word 8!

    Works fine (slight glitch I'll iron out).

    Anyway, did you just knock up that code or did you have it coded
    already?

    Well, Thanks for your help Dave.

    Bruce.
    ________
    SophiaHot
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:59 AM.

  10. #10
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Just knock it up before

  11. #11

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    I'm Stuck

    When closing this app (using the x)
    I notice 'Winword' is still active (using Ctrl-Alt-Del).

    I have unsuccesfully tried adding to the Form_Unload sub.
    the following in an attempt to close off Winword:
    Set wdDoc.Close, Set wdApp.Application.close
    wdDoc.Close = true......... Clutching at straws!

    Hmmmmm.

    I have done a search, and I have found heaps using
    Kill, Public Function.... yada yada yada.
    They seem to deal with Active windows apps though.


    Bruce
    ________
    HOW TO ROLL A JOINT
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:59 AM.

  12. #12
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Application.Quit should work...

    I don't know if i've declared Word correctly

  13. #13

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Yep

    The word declaration is OK.

    Had to use:

    Word.Application.Quit


    in the Unload_Form aswell to close of Winword.


    Thanks again.

    Bruce
    ________
    lesbians Webcam
    Last edited by Bruce Fox; Aug 14th, 2011 at 03:59 AM.

  14. #14
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Yeah, woops, thought i had put that in

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