using word to spell check text fields in vb2010

i am converting a VB6 app and when i try to implement the spellcheck from word I use the following code;

         Dim objWord As Object
        Dim objDoc As Object
        Dim strResult As String



        'Create a new instance of word Application for Content_Format
        objWord = CreateObject("word.Application")

        Select objWord.Version
            'Office 2000
            Case "9.0"
                objDoc = objWord.Documents.Add(, , 1, True)
                'Office XP
            Case "10.0"
                objDoc = objWord.Documents.Add(, , 1, True)
                'Office 2007
            Case "11.0"
                objDoc = objWord.Documents.Add(, , 1, True)
                'Office 2010
            Case "12.0"
                objDoc = objWord.Documents.Add(, , 1, True)
                'Office 97
            Case Else ' Office 97
                objDoc = objWord.Documents.Add
        End Select
        txtOriginal.Focus()
        objDoc.Content = DirectCast(txtOriginal.Text, String)
        objDoc.CheckSpelling()

-
- [b]this line of code fails with I Operator '-' is not defined for type "range" and type "integer"[/b]
-
        strResult = objDoc.Content.Substring(0, Len(objDoc.Content - 1))
        'strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)

        If txtOriginal.Text = strResult Then
            ' There were no spelling errors, so give the user a
            ' visual signal that something happened
            MsgBox("The spelling check of Content_Format is complete.", vbInformation + vbOKOnly)
        End If
        ''Clean up
        objDoc.Close(False)
        objDoc = Nothing
        objWord.Application.Quit(True)
        objWord = Nothing
        txtOriginal.Text = strResult 

Open in new window


somehow i don't think the line
  objDoc.Content = DirectCast(txtOriginal.Text, String)
is actually moving the textfield content correctly.  how can i correct this/
Larry RungrenDirector of TechnologyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
I would use
objDoc.Content.Text = DirectCast(txtOriginal.Text, String)

Open in new window

or just
objDoc.Content.Text =txtOriginal.Text

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry RungrenDirector of TechnologyAuthor Commented:
fast accurate required one other line to use the same change and all is now working
Jacques Bourgeois (James Burger)PresidentCommented:
The DirectCast seems useless however, it just adds extra overhead.

txtOriginal.Text is already a String, to there is no need to cast it to a String.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.