PDA

View Full Version : PowerPoint Names Change with Layout Selection



Grasor
06-23-2015, 12:43 PM
Hi all,

I've been doing some good things in Excel VBA but was recently tasked to automate some simple but repetitive tasks in PowerPoint.

I've created a User Form with several text boxes that the user fills out and then those fields fill in text boxes and text placeholders (from layouts) on every slide available in the project. The code works great right up until someone changes a layout. The selected layout just changes a graphic on the slide and alters the location of the text placeholders depending on what types of images are being added to the slide. However, I noticed the names I have assigned to the text placeholders (which are located on the layouts) lose the names I have assigned to them every time the layout is changed. In fact, they appear to be incrementing everytime the layout is changed, so if I revert to the previous layout it's an entirely different number than it was before.

Is there a better way to do this? Or can the names somehow be preserved?

Thanks
G

Grasor
06-23-2015, 01:56 PM
Update: I'm having the same issue trying to attack this with Tags and Shape IDs.

Paul_Hossler
06-23-2015, 04:42 PM
I noticed the names I have assigned to the text placeholders (which are located on the layouts) lose the names I have assigned to them every time the layout is changed.

Changed how? Deleted? Re-positioned? New or added?

Going from a 1-column content to a (for ex.) 2-col content?

Are you using a PPTM or POTM for your starting layout?

Can you post a 1 or 2 slide sample presentation with the macro AND a complete description of the user actions that break the names?

Grasor
06-23-2015, 09:08 PM
Changed how? Deleted? Re-positioned? New or added?

Going from a 1-column content to a (for ex.) 2-col content?

Are you using a PPTM or POTM for your starting layout?

Can you post a 1 or 2 slide sample presentation with the macro AND a complete description of the user actions that break the names?

The custom name I assigned to a shape on a slide that is inherited from a layout is assigned a new name by PPT if that slide is assigned a new layout. This is easy to reproduce. Unfortunately I can't provide an example but maybe I could work up something basic if you can't reproduce it. I am using a PPTM.

i did find a workaround by writing code that just creates a correctly sized, positioned, and formatted text box if the slide custom layout had a particular name. This took a lot more effort bust mostly because I had not done this before.

John Wilson
06-24-2015, 08:17 AM
Shapes on a slide don't usually inherit the name, id or tags from the custom layout IF they are empty placeholders. You need to explain EXACTLY what you are doing and what you need to achieve. I see you have asked this same question elsewhere - always best to mention this

Grasor
06-24-2015, 02:01 PM
Shapes on a slide don't usually inherit the name, id or tags from the custom layout IF they are empty placeholders. You need to explain EXACTLY what you are doing and what you need to achieve. I see you have asked this same question elsewhere - always best to mention this

I tried to link this to my similar post on MSDN but it appears it is forbidden by this forum to do so. In any event, I replied to you there. Yes, I am using empty placeholders.

What I'm trying to do isn't that complicated to explain but I appear to be missing the mark. I'll simplify.




I have a single slide presentation with two different custom layouts for that slide.
I am using a VBA enabled PPTM userform to populate a textbox in the header and two text placeholders that change position depending on the layout chosen.

The placeholders are empty save for the placeholder description.


I name the header textbox "HeaderTextBox" and the two text placeholders "Caption1" and "Caption2"
My VBA code then looks for the shapes and adds text from the userform by executing






With ActivePresentation.Slides(1)
.Shapes("HeaderTextBox").TextFrame.TextRange.Text = UFrm_Information.TBox_HeaderData
.Shapes("Caption1").TextFrame.TextRange.Text = UFrm_Information.TBox_Caption1
.Shapes("Caption2").TextFrame.TextRange.Text = UFrm_Information.TBox_Caption2
End With





This works as intended UNLESS I change from the first layout to the second. Then my HeaderTextBox,Caption1,Caption2 names for those shapes are replaced by default names assigned by PowerPoint. I.e. Caption1 becomes Text Placeholder 72.

John Wilson
06-24-2015, 02:08 PM
I answered over there too

EMPTY text placeholders are remade when you apply a new layout and the names , tags etc of placeholders are lost.

Add code to temporarily add dummy text to empty placeholders and remove it after changing the layout.