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
Jean-Guy Marcil - 27 Aug 2006 01:11 GMT
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
[quoted text clipped - 63 lines]
>
> End If
Have you tried this:
Private Sub btnExit_Click()
Application.Quit wdDoNotSaveChanges
End Sub

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
elle0612 - 27 Aug 2006 09:06 GMT
Sorry, I didn't know I could do that addition with applicaton.quit.
Thanks
> elle0612 was telling us:
> elle0612 nous racontait que :
[quoted text clipped - 72 lines]
> Application.Quit wdDoNotSaveChanges
> End Sub
Jean-Guy Marcil - 28 Aug 2006 15:48 GMT
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.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org