Solved

Close Word spell check from VB6

Posted on 2008-10-12
2
399 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 125 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
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.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 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