Solved

Spell Checker gets an error at the first first line

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now