標題:
[發問]
工作表另存檔案及被保護工作表
[打印本頁]
作者:
missbb
時間:
2017-12-3 21:37
標題:
工作表另存檔案及被保護工作表
各位大大, 我有下列將工作部內的工作表另存獨立WORKBOOK, 但想另存後的工作表是已受保護的工作表, 解除PASSWORD是1, 請賜教?
Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
xWs.Copy
Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls" [color=Red](問題, 如何另存新檔後, 每個檔案都已保護了工作表, PASSWORD 是"1")[/color]
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
複製代碼
作者:
Hsieh
時間:
2017-12-4 09:43
回復
1#
missbb
Sub Splitbook()
XPath = Application.ActiveWorkbook.Path
For Each xws In Sheets
xws.Copy '複製
ActiveSheet.Protect 1 '保護工作表密碼1
With ActiveWorkbook
.SaveAs XPath & "\" & xws.Name & ".xls", , 1 '另存新檔並保護活頁簿密碼1
.Close '關閉檔案
End With
Next
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)