[RESOLVED] Close template if not doc not saved
I made a template in WORD
But what am trying to do now is that
When the template is open should be a wdDialogFileSaveAs should be started
But when the user clicks on cancel the template should be closed and not be used anymore
i thought of solving it like that
MsgBox "SAVE befor you start … "
activedocument.Saved = False
CommandBars.FindControl(ID:=3).Execute
If activedocument.Saved Then
' MsgBox "The document was saved."
' If MsgBox("you dont want to save the doc? ?", vbYesNo + vbQuestion, SAVING) = vbNo Then
' activedocument.Close
'
activedocument.Close
RecentFiles(1).Open
yesNo = yes
Else
MsgBox "somting "
But i always get Error or it doesn’t work good .. :afrog:
Help .. any tips ?
Re: Close template if not doc not saved
Add the following code in a module in your template:
VB Code:
Sub AutoOpen()
Dim dlgSaveAs As Dialog
Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
With dlgSaveAs
BeginSave:
If Not .Display = -1 Then
If MsgBox("you dont want to save the doc? ?", vbYesNo + vbQuestion) = vbNo Then
ActiveDocument.Close
Else
GoTo BeginSave
End If
Else
.Format = wdFormatDocument
.Execute
End If
End With
End Sub
Re: Close template if not doc not saved
:eek:
it worked
thxxxxxxxxxxxxxxxxx u r the best ! :wave:
am comming to you forum everyday :D
Re: Close template if not doc not saved
Please mark the thread "RESOLVED" if you got an answer to your questions.
Re: Close template if not doc not saved
Re: Close template if not doc not saved
Quote:
Originally Posted by String-0
how where what ??
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Re: [RESOLVED] Close template if not doc not saved
ok sorry guys ;; i just did it ..
thx alot again