O que tenho que alterar aqui, o caminha eu sei precisa altera mais algo?
Coloquei meu endereço mais não foi.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
.CommandBars("Cell").Reset
End With
Application.DisplayAlerts = False
Dim awb As Workbook, BackupFileName As String, i As Integer, OK As Boolean
If TypeName(ActiveWorkbook) = "Nothing" Then Exit Sub
Set awb = ActiveWorkbook
If awb.Path = "" Then
Application.Dialogs(xlDialogSaveAs).Show
Else
BackupFileName = awb.FullName
i = 0
While InStr(i + 1, BackupFileName, ".") > 0
i = InStr(i + 1, BackupFileName, ".")
Wend
If i > 0 Then BackupFileName = Left(BackupFileName, i - 1)
BackupFileName = BackupFileName & ".bak"
OK = False
On Error GoTo NotAbleToSave
With awb
Application.StatusBar = "Saving this workbook..."
.Save
Application.StatusBar = "Saving this workbook backup..."
.SaveCopyAs BackupFileName
OK = True
End With
End If
NotAbleToSave:
Set awb = Nothing
Application.StatusBar = False
If Not OK Then
MsgBox "Backup Copy Not Saved!", vbExclamation, ThisWorkbook.Name
End If
ThisWorkbook.Save
End Sub
Tentar não é saber, é ter a certeza que vai descobrir
Dicas excel, vba, Access http://vbaedit.blogspot.com.br/
Postado : 31/08/2014 11:53 am