Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Close Word spell check from VB6

Posted on 2008-10-12
2
Medium Priority
?
413 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

927 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