PDA

View Full Version : PowerPoint 2007 - VBA Code that Distinguishes between Different Master Slides



SASS2007
10-28-2010, 11:44 AM
Hi there,

I'm creating a presentation template in PowerPoint 2007 and am using VBA to create a macro that will update text boxes on multiple master slides with the information provided in a userform.

Basically I have two master slides, one I've called TitleMaster (as this function is no longer available in 2007) and the second is called SlideMaster. When I run the macro, everything works fine for the first slide master, but when it gets to the code for the second master, it displays a run-time error saying that the item is not found.

Here is my code:


'updates TitleMaster slide master with content as provided in userform
ActivePresentation.SlideMaster.Shapes("txtTitleofSub").TextFrame.TextRange.Text = frmData.txtTitleofSub.Value
ActivePresentation.SlideMaster.Shapes("txtMeetDate").TextFrame.TextRange.Text = frmData.txtMeetDate.Value
ActivePresentation.SlideMaster.Shapes("txtEMTExec").TextFrame.TextRange.Text = frmData.txtExecName.Value _
& ", " & frmData.txtExecTitle.Value

'updates SlideMaster slide master with content as provided in userform
ActivePresentation.SlideMaster.Shapes("txtComName").TextFrame.TextRange.Text = frmData.txtComName.Value
ActivePresentation.SlideMaster.Shapes("txtDate").TextFrame.TextRange.Text = frmData.txtMeetDate.Value


The code only stops working when it hits "txtComName" as it appears on the second master slide.

Is there a way to distinguish between different master slides in the above code?

Any help is greatly appreciated!! I know there has to be a way to do it and I'm losing my mind over here :banghead:

Thanks!!

John Wilson
10-29-2010, 02:07 AM
I think you are misunderstanding the new Master structure in 2007 / 2010

The Master slide can have several Custom layouts associated with it. These include the original Title and slide master layouts which are usually the first and second layout.

Add your shapes to these layouts and address them like this

ActivePresentation.SlideMaster.CustomLayouts(1).Shapes("Whatever").TextFrame.TextRange =
ActivePresentation.SlideMaster.CustomLayouts(2).Shapes("Whatever").TextFrame.TextRange =

rekhasein
11-10-2010, 03:58 AM
I need to have a macro that prints out different files during my sideshow, but so far when I click the "Print" button I made, the slide show stops, opens the file to be printed, and then I have to click Resume Slide Show to continue with my slide show. Is there a way this printing can be done so it's invisible? Does the file to be printed have to be opened or can I just say in my macro to Print a certain file? thanks for any advice!