1
我想創建一個用密碼加密的備份excel工作簿,只要按下按鈕保存即可。創建受密碼保護的備份
到目前爲止,我有這個,但仍不容弄清楚如何保護所有新.XLSM文件與密碼,這樣沒有人不容做備份文件的改變不知道密碼。在不同的文件夾中保存和創建備份文件。
謝謝。
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim DestinationFolder As String
Dim WbName As String
Dim WbExtension As String
Dim WbNewPath As String
Dim sHostName As String
sHostName = Environ$("computername")
DestinationFolder = "C:\Users\An\Dropbox\Orders - backup"
If DestinationFolder = "" Or Dir(DestinationFolder, vbDirectory) = vbNullString Then
MsgBox "The destination folder's path is incorect!", vbCritical, "Wrong folder's path"
Exit Sub
End If
WbName = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))
WbExtension = Right$(ThisWorkbook.Name, Len(ThisWorkbook.Name) - InStrRev(ThisWorkbook.Name, "."))
WbNewPath = DestinationFolder & "\" & WbName & sHostName & "(" & Format(Now(), "dd.mm.yyyy - hh.mm") & ")." & WbExtension
ThisWorkbook.SaveCopyAs WbNewPath
End Sub
能否請你幫我修改我的另存爲功能碼?我不知道如何處理這樣一個複雜的(對我來說)需要 - 文件名中的日期,時間和計算機名稱。感謝您的努力。 – pandemic 2015-02-09 20:55:11