Solved

Spell Checker gets an error at the first first line

Posted on 2002-07-24
5
169 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

785 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