[英]Pasting into the Master slide
我有一個代碼可以將對象從幻燈片粘貼到活動幻燈片。 如何使代碼粘貼到母版中?
Public Function AddShapeBooktitle()
Dim s As String, p As Presentation, o As Shape
'open the file and copy the object
If CommandBars.ActionControl.Parameter <> "" Then
s = Ini.GetResourcePath & CG_ADDIN_NAME & "\" & CG_INSERT_FOLDER & CG_BOOKTITLE_FOLDER & CommandBars.ActionControl.Parameter
Set p = Presentations.Open(s, ReadOnly:=True, WithWindow:=msoFalse)
p.Slides(1).Shapes.Range().Copy
p.Close
ActiveWindow.Selection.SlideRange(1).Shapes.Paste
Else
MsgBox "The Shape file name is missing.", vbExclamation, "Shape file name missing."
End If
End Function
感謝任何專業的幫助! 謝謝!
您需要確定當前幻燈片的自定義布局,然后將形狀粘貼到SlideMaster中的相應布局中。 這樣的事情在單個演示文稿中起作用。 如果您在可能具有不同SlideMaster
集合的多個演示文稿之間進行工作,則可能需要以某種方式調整邏輯。 但這是一個總體思路:您需要確定哪個 SlideMaster.CustomLayouts
將是Paste
操作的目標。
Option Explicit
Sub foo()
Dim p As Presentation
Dim sld As Slide
Dim layout As CustomLayout
Set p = ActivePresentation
Set sld = p.Slides(1)
layout = sld.CustomLayout.Index
sld.Shapes.Range().Copy
p.SlideMaster.CustomLayouts(layout).Shapes.Paste
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.