Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Problem on closing application - Word 2000

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
elle0612 - 26 Aug 2006 23:38 GMT
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.