Results 1 to 3 of 3

Thread: User defined type error when tyring to use word's SpellingSuggetions

  1. #1

    Thread Starter
    Junior Member MrLudwig's Avatar
    Join Date
    Jul 2000
    Location
    Behind you!
    Posts
    24

    User defined type error when tyring to use word's SpellingSuggetions

    Can someone tell me what I'm doing wrong? I get a compile error saying 'User-defined type not defined' when trying to declare a variable of type spellingsuggestions (word automation).

    I can create an instance of the word object and use various other methods/properties of it which all work fine. But as soon as I try to
    VB Code:
    1. Dim SpellSuggestions as wdapp.spellingsuggestions
    I get the error.

    wdApp is created using the code
    VB Code:
    1. Dim wdApp As Object
    2. Set wdApp = CreateObject("Word.Application")

    I'm fairly new at this automation stuff, so if its a stupid mistake on my part that is glaringly obvious to everyone else, please forgive my ignorance.

    Cheers.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Since you are using late-binding to create the word object I am assuming you do not have a reference to the Word library in your vb project.

    This means you would have to declare the SpellSuggestions variable as an Object as well.

    VB Code:
    1. Dim SpellSuggestions as Object
    2.  
    3. Set SpellSuggestions = wdapp.GetSpellingSuggestions("Incorect")

  3. #3

    Thread Starter
    Junior Member MrLudwig's Avatar
    Join Date
    Jul 2000
    Location
    Behind you!
    Posts
    24
    Ah, so it was a stupid mistake on my part.

    I had written the code originally using early binding and thus with a reference to the Word type library.

    I am currently writing v2 of the app of which this code is part, using late binding as the users have different versions of office.

    Thanks for your help brucevde, it works perfectly.

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