Solved

Spell Checker gets an error at the first first line

Posted on 2002-07-24
5
170 Views
Last Modified: 2010-05-02
Private Sub CheckSpelling()
Dim oSpellChecker As Object
Dim stText As String
Dim stNew_Text As String
Dim iPosition As Integer

    On Error GoTo OpenError
   
   
    Set oSpellChecker = CreateObject("Word.Basic")
   
    'oSpellChecker.FileNew
    'oSpellChecker.Insert ActiveForm.rtbMain.Text
    'oSpellChecker.ToolsSpelling
    'oSpellChecker.EditSelectAll
    'stText = oSpellChecker.Selection()
    'oSpellChecker.FileExit 2

    'If Right$(stText, 1) = vbCr Then _
    '  stText = Left$(stText, Len(stText) - 1)
    'stNew_Text = ""
    'iPosition = InStr(stText, vbCr)
    'Do While iPosition > 0
    '  stNew_Text = stNew_Text & Left$(stText, iPosition - 1) & vbCrLf
    '  stText = Right$(stText, Len(stText) - iPosition)
    '  iPosition = InStr(stText, vbCr)
    'Loop
   
    'stNew_Text = stNew_Text & stText
    '
    'ActiveForm.rtbMain.Text = stNew_Text
    '
    'MsgBox "Spell Check Complete"
   
    'Exit Sub

OpenError:
    MsgBox "Error"
End Sub




I commented out all the stuff except for Set oSpellChecker = CreateObject("Word.Basic") and it still gets an error. It doesn't get a syntax error or anything, but the msgbox pops up. What did I do wrong?
0
Comment
Question by:sjaguar13
5 Comments
 
LVL 5

Accepted Solution

by:
RainUK earned 200 total points
ID: 7174959
you have to leave the :

Exit Sub

statement in, otherwise the compiler will process the command to launch the msgbox!

Don't worry about leaving Exit Sub in, if an error occurs the compiler will goto the OpenError label!

Is this understandable?????
0
 

Expert Comment

by:franbane
ID: 7175874
Also, have you referenced Word in the project?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8040569
Hi sjaguar13,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept RainUK's comment(s) as an answer.

sjaguar13, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8095690
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question