Problem on closing application - Word 2000

E

elle0612

I have finally put this application together, but am having trouble closing
every single document in the project. There always seems to be one open (the
actual template document I think, so that when the exit button is clicked to
close the application, the user is asked if he/she wants to save the document
- because I only have a userform visible, I don't want this message to appear
- I just want every document to close and then the application to quit
without any messages - I must be missing something, here's all the code ...
It consists of a blank template document coded, with links to two outer
files, pre-printed with some text, and bookmarked for text from the text
boxes. The checking of a box dictates which document is loaded.

Sub thisMacro()
'
' thisMacro Macro
' Macro created 15/08/2006
'
Application.Visible = False
UserForm1.Show

End Sub




Private Sub btnExit_Click()
Application.Quit
End Sub

Private Sub CommandButton1_Click()

If cbxDouble.Value = True Then
Documents.Open FileName:="C:\Documents and Settings\My Documents\double
sheet.doc"

With ActiveDocument
..Bookmarks("Text1").Range.InsertBefore tbxOne
..Bookmarks("Text2").Range.InsertBefore tbxOne
etc.............

Me.tbxOne.Text = ""
Me.tbxTwo.Text = ""
Me.tbxThree.Text = ""
Me.tbxFour.Text = ""

ActiveDocument.PrintOut
ActiveDocument.Close wdDoNotSaveChanges

Else

Documents.Open FileName:="C:\Documents and Settings\\My Documents\single
sheet.doc"

With ActiveDocument
..Bookmarks("Text106").Range.InsertBefore tbxThree
..Bookmarks("Text107").Range.InsertBefore tbxThree
etc............
End With

Me.tbxOne.Text = ""
Me.tbxTwo.Text = ""
Me.tbxThree.Text = ""
Me.tbxFour.Text = ""

ActiveDocument.PrintOut
ActiveDocument.Close wdDoNotSaveChanges

End If
 
J

Jean-Guy Marcil

elle0612 was telling us:
elle0612 nous racontait que :
I have finally put this application together, but am having trouble
closing every single document in the project. There always seems to
be one open (the actual template document I think, so that when the
exit button is clicked to close the application, the user is asked if
he/she wants to save the document
- because I only have a userform visible, I don't want this message
to appear
- I just want every document to close and then the application to quit
without any messages - I must be missing something, here's all the
code ... It consists of a blank template document coded, with links
to two outer files, pre-printed with some text, and bookmarked for
text from the text boxes. The checking of a box dictates which
document is loaded.

Sub thisMacro()
'
' thisMacro Macro
' Macro created 15/08/2006
'
Application.Visible = False
UserForm1.Show

End Sub




Private Sub btnExit_Click()
Application.Quit
End Sub

Private Sub CommandButton1_Click()

If cbxDouble.Value = True Then
Documents.Open FileName:="C:\Documents and Settings\My
Documents\double sheet.doc"

With ActiveDocument
.Bookmarks("Text1").Range.InsertBefore tbxOne
.Bookmarks("Text2").Range.InsertBefore tbxOne
etc.............

Me.tbxOne.Text = ""
Me.tbxTwo.Text = ""
Me.tbxThree.Text = ""
Me.tbxFour.Text = ""

ActiveDocument.PrintOut
ActiveDocument.Close wdDoNotSaveChanges

Else

Documents.Open FileName:="C:\Documents and Settings\\My
Documents\single sheet.doc"

With ActiveDocument
.Bookmarks("Text106").Range.InsertBefore tbxThree
.Bookmarks("Text107").Range.InsertBefore tbxThree
etc............
End With

Me.tbxOne.Text = ""
Me.tbxTwo.Text = ""
Me.tbxThree.Text = ""
Me.tbxFour.Text = ""

ActiveDocument.PrintOut
ActiveDocument.Close wdDoNotSaveChanges

End If

Have you tried this:

Private Sub btnExit_Click()
Application.Quit wdDoNotSaveChanges
End Sub


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

elle0612 was telling us:
elle0612 nous racontait que :
Sorry, I didn't know I could do that addition with applicaton.quit.

If I might offer a piece of advice, it might be useful for your own learning
process to get into the habit of checking out VBA methods/properties/objects
in the on-line help. In this case, you could have selected "Quit" in your
code and hit F1. This would have taken you directly to the help page
regarding Quit.
This is how I have learned most of what I know (by using the on-line help).
Sometimes I do not know if a method will allow me to do such and such, so I
hit F1, read the text and check out the examples.

Some help topics are not all that clearly written, but most are OK.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top