Solved

Spell Checker gets an error at the first first line

Posted on 2002-07-24
5
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

632 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