Solved

Close Word spell check from VB6

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

821 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