Consulting

Results 1 to 7 of 7

Thread: PowerPoint Names Change with Layout Selection

  1. #1
    VBAX Regular
    Joined
    Apr 2015
    Posts
    6
    Location

    PowerPoint Names Change with Layout Selection

    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

  2. #2
    VBAX Regular
    Joined
    Apr 2015
    Posts
    6
    Location
    Update: I'm having the same issue trying to attack this with Tags and Shape IDs.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    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?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Regular
    Joined
    Apr 2015
    Posts
    6
    Location
    Quote Originally Posted by Paul_Hossler View Post
    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.

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Regular
    Joined
    Apr 2015
    Posts
    6
    Location
    Quote Originally Posted by John Wilson View Post
    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.

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •