Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot quit word 1

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
Hi all:

I have a VB program that will not allow me to quit Word without clicking the Alert upon closing. I've used the same code in .Net and it works fine.

Code:
Public Sub MergeDoc(ByVal DocName As String, ByVal SaveName As String)
        
        If WD.Visible = False Then WD.Visible = True
        OpenDocument (DocName)
        
        With WD
            
            With .ActiveDocument.MailMerge
                .Destination = Word.WdMailMergeDestination.wdSendToNewDocument
                .Execute
            End With
        
          On Error GoTo NoFile
        End With
        SaveAs (SaveName)

        Select Case SaveName
            Case DefPath & "Letters\JuvExpired" & sM & sD & sY & ".doc"
                Expired = CountPages()
                InsertData "EXPIRED", "LETTER", Expired, "JuvExpired" & sM & sD & sY & ".doc"

            Case DefPath & "Letters\JuvDecline" & sM & sD & sY & ".doc"
                Denied = CountPages()
                InsertData "DECLINED", "LETTER", Denied, "JuvDecline" & sM & sD & sY & ".doc"

            Case DefPath & "Letters\JuvInvalid" & sM & sD & sY & ".doc"
                Invalid = CountPages()
                InsertData "INVALID", "LETTER", Invalid, "JuvInvalid" & sM & sD & sY & ".doc"

        End Select
        [b][i]WD.DisplayAlerts = wdAlertsNone[/i][/b]
        WD.ActiveDocument.Close (False)
        Exit Sub
NoFile:
            
            WD.ActiveDocument.Close (False)
       
End Sub

Public Sub SaveAs(ByVal FileName As String)
        WD.ActiveDocument.SaveAs (FileName)
End Sub

Public Sub QuitWord()
        [b][i]WD.DisplayAlerts = wdAlertsNone[/i][/b]
        On Error GoTo QuitERR
        WD.ActiveDocument.Close (False)
QuitERR:
        WD.Quit
        Set WD = Nothing
End Sub

I have bolded the Alert lines.


Any help will be greatly appreciated.

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
How about Application.Quit wdDoNotSaveChanges

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top