承認済みの企業標準である一連のカスタム レイアウトがあります。1 つのマスター レイアウトと 11 のカスタム レイアウトがあります。
ユーザーは古いコンテンツを貼り付ける可能性が高いため、貼り付けたスライドには対応するレイアウトが含まれることを認識しています。承認されたセットの一部ではないカスタム レイアウトを削除するボタンを作成する最良の方法は何ですか?
私が持っているコードは次のとおりですが、「Slide (unknown member) : Invalid Request. Can't delete master.」というエラーが表示されます。
どんな助けもありがたく受け取った!
Dim oDesign As design
For Each oDesign In ActivePresentation.Designs
'if design name is CC standard then
If oDesign.Name = CCSMNAME$ Then
Dim oLayout As CustomLayout
'Check the name of each layout against the permitted set, delete any that are additional
For Each oLayout In oDesign.SlideMaster.CustomLayouts
If oLayout.Name <> "Title Slide (Basic)" Or oLayout.Name <> "Title Slide (Standard Stock Image)" Or oLayout.Name <> "Title Slide (Image - Right)" Or oLayout.Name <> "Agenda" Or oLayout.Name <> "Body/Content (Basic)" Or oLayout.Name <> "Report (Approval and Disclaimer)" Or oLayout.Name <> "Report Body/Content" Or oLayout.Name <> "Divider" Or oLayout.Name <> "Quals (Basic -Right)" Or oLayout.Name <> "Quals (Basic - Left)" Or oLayout.Name <> "Content and Closing" Then
oLayout.Delete
End If
Next oLayout
Else
'Else, the Design found is not the CC Master so delete it
'(This runs for all remaining masters)
oDesign.Delete
End If
Next oDesign
私は現在、次のコードを使用しています-追加のスライドマスターをすべて削除する代わりに、シーケンスの次のマスターのみを削除して終了する理由を誰か知っていますか?
サブクリーンアップテンプレート()
'Declare some variables
Dim oDesign As design
Dim oDesigns As Designs
Dim oLayout As CustomLayout
Dim masterCount As Long
Dim layoutCount As Long
Dim strInUse As String
On Error Resume Next
For Each oDesign In ActivePresentation.Designs
If oDesign.Name = CCSMNAME$ Then
MsgBox "The script has found " & oDesign.SlideMaster.CustomLayouts.Count & " layouts in the CC Master. There should be 11 in total. An integrity check will now run to remove any non-approved slide layouts."
'Loop through set backwards to keep integrity of data set when deleting
For layoutCount = oDesign.SlideMaster.CustomLayouts.Count To 1 Step -1
Set oLayout = oDesign.SlideMaster.CustomLayouts(layoutCount)
Err.Clear
'Check the name of each layout against the permitted set, delete any that are additional
If checkAllowed(oLayout) = False Then
oLayout.Delete
End If
If Err <> 0 Then
strInUse = strInUse & oLayout.Name & " , "
End If
Next layoutCount
MsgBox ("Any additional layouts deleted, cleanup of CC Master completed.")
Else
'Else, a Slide Master has been found that is not the CC Master so delete it
MsgBox ("An additional Slide Master named " & oDesign.Name & " that is not CC approved has been detected. It is not in use, so it will be removed.")
oDesign.Delete
End If
Next oDesign
'Alert the user to any foreign slide designs found that couldn't be deleted
If Len(strInUse) > 0 Then
MsgBox "The following slide designs seem to be either in use, or protected: " & Left(strInUse, Len(strInUse) - 1)
End If
サブ終了
関数 checkAllowed(olay As CustomLayout) As Boolean
Select Case olay.Name
Case Is = "Title Slide (Basic)", _
"Title Slide (Image - Right)", _
"Title Slide (Standard Stock Image)", _
"Agenda", "Body/Content (Basic)", _
"Report (Approval and Disclaimer)", _
"Report Body/Content", _
"Divider", _
"Quals (Basic - Right)", _
"Quals (Basic - Left)", _
"Contact and Closing"
'Return true if any of the above names are a match
checkAllowed = True
Case Else
'Return false if no match found
checkAllowed = False
End Select
終了機能