Hi All,

When a user selectrs Save or SaveAs( both are the same to me),

I want to make some checks and if some of the checks return false, I want to cancel save or saveas procedure and prevent saving the file.

For instance users open the file from a template. The name of the file is "BA_Template.doc"

If user presses Save (or SaveAs), A dialogbox opens:

First I check whether user press cancel button, Then I display a warning message,
Then I check whether the name of the file is the with the templatename, if user does not change the name and opt to save the file with the temlate name (even to another folder) I want to display and error message and cancel the save procedure.

Below is my code but I played a lot with it so it isn't organised


'Sub CheckFileName(ByVal T As Boolean)
Function CheckFileName(T As Boolean)
'Do While Not SaveCase
                'With Dialogs(wdDialogFileSaveAs)
                    
                    
                        'Check whether user presses cancel button!
                        If Dialogs(wdDialogFileSaveAs).Show = 0 Then
                            SaveCancelled = True
                          
                          'Dialogs(wdDialogFileSaveAs).Name = "KOS_SWChangeAnalysisDocumentTemplate.docm"
                        
                        ElseIf ActiveDocument.Name = "KOS_SWChangeAnalysisDocumentTemplate.docm" Then
                            TemplateNameFound = True
                            FirstSave = True
                            TemplateNameNoChange = True
                            MsgBox "Dosya şablondan açılmış, farklı isimle kaydetmelisiniz!"
                            SaveCancelled = True
                                        
                        'ElseIf ActiveDocument.Name = "KOS_SWChangeAnalysisDocumentTemplate.docm" Then
                         '   TemplateNameNoChange = False
                          '  MsgBox "Dosya şablondan açılmış, farklı isimle kaydetmelisiniz!"
                           ' SaveCancelled = True
                        
                        Else
                            SaveCancelled = False
                            CheckFileName = True
                            
                        End If
                        'End If
                    'End If
                            
                        If SaveCancelled = True Then CheckFileName = False
                        
                        'If TemplateNameFound = True
                        
                            
                        'End If
                    
                    'End With
  '              Loop
End Function