Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Close Word spell check from VB6

Posted on 2008-10-12
2
Medium Priority
?
408 Views
Last Modified: 2013-11-26
I am using MSWord to check spelling in a VB6 text box.  The spell check itself works fine, but will not close properly.  MSWord is set as a public application:

Public AppWord As Application

Set AppWord = GetObject(, "Word.Application")

I would prefer to simply Quit the application when spell checking is complete. However, I get a MSWord alert to Save Changes which does not respond to the following SendKeys to close it out.  
 

Private Sub CmdExit_Click()
    With AppWord
        .DisplayAlerts = wdAlertsNone      'Do you want to save changes?
        .Quit
        SendKeys "{Right}"
        SendKeys "{Enter}"
    End With

    Set AppWord = Nothing
    Unload Me
End Sub

MSWord continues to run.  
0
Comment
Question by:lsmoore
[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
2 Comments
 
LVL 23

Accepted Solution

by:
irudyk earned 500 total points
ID: 22700010
Try the following revised code:
Private Sub CmdExit_Click()
    AppWord.Quit 0  '0 = exits word without saving changes to exisitng documents
    Set AppWord = Nothing
    Unload Me
End Sub

Open in new window

0
 

Author Closing Comment

by:lsmoore
ID: 31505539
Thanks.  That was exactly what I needed.  Lewis
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Suggested Courses

730 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