Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim flag As Boolean
flag = False
Do While Not flag
fm = Application.GetSaveAsFilename(fileFilter:="Excel files (*.xls),*.xls,All files (*.*),*.*")
If fm <> False Then
Application.EnableEvents = False
ActiveWorkbook.SaveCopyAs fm
Application.EnableEvents = True
flag = True
End If
Loop
SetAttr pathname:=fm, Attributes:=vbReadOnly
End Sub