保護對象有什麼辦法來存儲在VBA中.protection
對象,並使用存儲在對象的參數再使用它來保護表?使用在VBA
我知道這是可能存儲對象,但我不能用它來再次保護工作表。
我需要這個,因爲不同的表有不同的保護輪廓,我想在一個循環中使用這個。
Set wsp = workbookname.Sheets(sheetname).Protection
,並再次保護工作表,我想用這樣的:
workbookname.Sheets(sheetname).Protect wsp
保護對象有什麼辦法來存儲在VBA中.protection
對象,並使用存儲在對象的參數再使用它來保護表?使用在VBA
我知道這是可能存儲對象,但我不能用它來再次保護工作表。
我需要這個,因爲不同的表有不同的保護輪廓,我想在一個循環中使用這個。
Set wsp = workbookname.Sheets(sheetname).Protection
,並再次保護工作表,我想用這樣的:
workbookname.Sheets(sheetname).Protect wsp
,你可以如使用設置爲您的每個配置文件創建s類,例如。 HTH
' Class module SomeProtectionProfile
Private m_password As Variant
Private m_drawingObjects As Variant
Private m_contents As Variant
Private m_scenarios As Variant
Private m_userInterfaceOnly As Variant
Private m_allowFormattingCells As Variant
Private m_allowFormattingColumns As Variant
Private m_allowFormattingRows As Variant
Private m_allowInsertingColumns As Variant
Private m_allowInsertingRows As Variant
Private m_allowInsertingHyperlinks As Variant
Private m_allowDeletingColumns As Variant
Private m_allowDeletingRows As Variant
Private m_allowSorting As Variant
Private m_allowFiltering As Variant
Private m_allowUsingPivotTables As Variant
Private Sub Class_Initialize()
m_password = "SomePsw1"
' and others like m_drawingObjects, m_contents ...
End Sub
Public Sub Protect(sheetToProtect As Worksheet)
sheetToProtect.Protect Password:=m_password ' , ... and others
End Sub
' Standard module
Sub main()
With New SomeProtectionProfile
.Protect workbookname.Sheets(sheetname)
End With
End Sub
我不覺得有什麼。您將不得不求助於「Select Case」或「If」語句,以不同的方式保護工作簿中的不同工作表。 – L42