简体   繁体   English

如何在PowerPoint幻灯片母版中更改特定的文本框

[英]How to change a specific textbox in a powerpoint slide master

I have a powerpoint that uses different Master layouts on the slide Master. 我有一个幻灯片,在幻灯片母版上使用不同的母版版式。 Every time we do an update, a specific textbox on a specifc Master slides needs to be updated. 每次我们进行更新时,特定主幻灯片上的特定文本框都需要更新。 I would like to do so with a macro. 我想用一个宏。

IE I have a slide master with a Generic Title_Slide and 2 variations under that. IE浏览器我有一个幻灯片母版,带有通用的Title_Slide和2个变体。 It has a "Generic Bullet_slide" with 10 variations under that. 它有一个“通用Bullet_slide”,其下有10个变体。

on the "Generic Bullet_Slide" there is a textbox that contains two lines: "CONFIG. MGR: [your name], [your code], [your phone #]" "FILE NAME: [name of file]" 在“ Generic Bullet_Slide”上,有一个包含两行的文本框:“ CONFIG。MGR:[您的名字],[您的代码],[您的电话号码]”“ FILE NAME:[文件名]”

every time we send the project out, we need to update the fields in [] manually. 每次我们发送项目时,我们都需要手动更新[]中的字段。 If we forget its bad news. 如果我们忘记了它的坏消息。

I have seen how to loop through all slides, then all shapes to find text boxes. 我已经看到了如何遍历所有幻灯片,然后遍历所有形状以查找文本框。 Can I find a boxs that specifically has those words in it ("CONFIG. MGR:" and "FILE NAME:") ? 我可以找到一个专门包含这些单词的框(“ CONFIG。MGR:”和“ FILE NAME:”)吗?

Can I search "layout" slides only? 我只能搜索“布局”幻灯片吗? how do I target anything on the layout slide instead of a normal slide? 如何定位布局幻灯片而不是普通幻灯片的任何内容?

thanks a bunch. 谢谢一堆。

You can use the object named 'ActivePresentation.Designs(x).SlideMaster.CustomLayouts' to access each custom-layout slide in SlideMaster Designs. 您可以使用名为“ ActivePresentation.Designs(x).SlideMaster.CustomLayouts”的对象来访问SlideMaster Designs中的每个自定义布局幻灯片。 (You can have more than 1 design in a presentation.) (一个演示文稿中可以有多个设计。)

Accessing sub-objects in the custom-layout slides is just like dealing with those in the normal slides. 访问自定义布局幻灯片中的子对象就像处理普通幻灯片中的子对象一样。

I think you can try the following automation code: 我认为您可以尝试以下自动化代码:

Option Explicit
Option Compare Text 'Ignore Upper/Lower case

Sub UpdateCustomLayouts()

    Dim DSN As Design
    Dim CL As CustomLayout
    Dim shp As Shape
    Dim mName As String, mCode As String, mPhone As String, fName As String

    'First, change following variables before running this macro
    mName = "Your name"
    mCode = "Your code"
    mPhone = "0123456789"
    fName = ActivePresentation.Name

    'Loop each customlayouts
    For Each DSN In ActivePresentation.Designs
        For Each CL In DSN.SlideMaster.CustomLayouts
            For Each shp In CL.Shapes
                If shp.HasTextFrame Then

                    'find and update textboxes
                    With shp.TextFrame.TextRange
                        If .Text Like "CONFIG. MGR:*" Then
                            .Text = "CONFIG. MGR: " & mName & ", " & mCode & ", " & mPhone
                        ElseIf .Text Like "FILE NAME:*" Then
                            .Text = "FILE NAME: " & fName
                        End If
                    End With

                End If
            Next shp
        Next CL
    Next DSN

End Sub

As I mentioned, first change variables like 'mName, mCode, mPhone, fName' before running. 如前所述,在运行之前,请先更改变量,例如“ mName,mCode,mPhone,fName”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM