Solved

Spell Checker gets an error at the first first line

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

759 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

24 Experts available now in Live!

Get 1:1 Help Now