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
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