I've been working on a VBA macro that automatically creates watermark on a master slide for multiple named people and then automatically saves it to separate PDFs. All of this works well now. However, some presentations I may need to watermark, have multiple themes applied to different slides. (eg. first half is using theme 1 and the second half is using theme 2) Each theme has a separate master slide. When I use ActivePresentation.SlideMaster, this only affects the top master slide in the Slide Master view. How would I go about accessing master slides for the other themes?
Edit: Here is the code I have. The xlVariables come from an Excel file. The watermark line refers to the text box that is put furthest back. I searched for a way to access multiple master slides but I couldn't find anything on it.
xlName = Range("A" & CStr(count))
xlCompany = Range("B" & CStr(count))
xlDate = Range("C" & CStr(count))
xlMail = Range("D" & CStr(count))
'Create the watermark
ActivePresentation.SlideMaster.Shapes(1).TextFrame.TextRange.text = "Confidential - Do Not Share" & vbNewLine & "Issued to " _
& xlName & vbNewLine & "on " & xlDate & vbNewLine & xlCompany & " - Internal Use Only"
CodePudding user response:
Here's some sample code that will do something (that you define) to each master (oDes.SlideMaster in the code) and layout (oLay) in a presentation.
Modify DoSomethingWithShapeContainer to do whatever it is you need to do to each master/layout.
Sub AllMastersAndLayouts()
Dim oLay As CustomLayout
Dim oDes As Design
With ActivePresentation
For Each oDes In .Designs
Call DoSomethingWithShapeContainer(oDes.SlideMaster)
For Each oLay In oDes.SlideMaster.CustomLayouts
Call DoSomethingWithShapeContainer(oLay)
Next
Next
End With
End Sub
Sub DoSomethingWithShapeContainer(oShapeContainer As Object)
With oShapeContainer.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 20, 200, 50)
.TextFrame.TextRange.Text = "I did something here"
End With
End Sub