Solved

Close Word spell check from VB6

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

910 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

20 Experts available now in Live!

Get 1:1 Help Now