+ -
当前位置:首页 → 问答吧 → 请教PPT之VBA问题,急!!!

请教PPT之VBA问题,急!!!

时间:2010-09-23

来源:互联网

请教PPT的VBA中语句:
Shapes.Placeholders(index)
其中index的值有多少,各对应什么类型?

作者: willson_62   发布时间: 2010-09-23

没用过PPT,
刚查了一下帮助,另根据一般VBA 的理解,是指幻灯片中所有占位符的集合的序列
INDEX为指定集合中对象的序列号

作者: yvhgydn   发布时间: 2010-09-23

能提供序列号对应的对象吗?谢谢!

作者: willson_62   发布时间: 2010-09-23

序列号为LONG,其实就是对象集合中该对象的序号
对象是Placeholder:幻灯片中的占位符

作者: yvhgydn   发布时间: 2010-09-23

Placeholders集合代表指定幻灯片中占位符的所有 Shape 对象的集合。Placeholders 集合中的每个 Shape 对象代表一个占位符,占位符可以是文本、图表、表格、组织结构图或其他类型的对象。如果幻灯片有标题,则标题是集合中的第一个占位符。因此,关键看你的模板上启用了哪些占位符了。

作者: laose   发布时间: 2010-09-23

我只知道几个索引值的对应对象,比如,值14,对应的是占位符;值3,好像对应的标题。

作者: willson_62   发布时间: 2010-09-23

举个示例
ActivePresentation.Slides(1).Shapes.Placeholders.count
当前PPT中第一个幻灯片中所有占位符的数量(count),解释的也许有些不正确,因是刚刚查阅帮助,请高手指正

作者: yvhgydn   发布时间: 2010-09-23

laose:
呵呵,我就是希望得到文本、图表、表格、组织结构图等这些对象对应的索引值!!

作者: willson_62   发布时间: 2010-09-23

引用:
原帖由 willson_62 于 2010-9-23 13:28 发表
laose:
呵呵,我就是希望得到文本、图表、表格、组织结构图等这些对象对应的索引值!!
呵呵,看来楼主要先把VBA的相关书藉看一下了,明白一个大致的构架

作者: yvhgydn   发布时间: 2010-09-23

实话说,Placeholders集合中对象的索引值并不重要,因为03与07/10就有所不同。你可以考虑,对占位符对象重新命名,然后再定位。
你如果方便,可在03和10的母板中分别用Debug.Print Shapes.Placeholders(2).Id  来看看其ID差别有多大。

作者: laose   发布时间: 2010-09-23

谢谢laose朋友的回答,我在国外网站找到一段检测Placeholders集合中对象的索引值的脚本,粘贴如下,希望对大家有用!

Sub Object_Types_on_This_Slide()
    'Refers to each object on the current page and returns the Shapes.Type
    'Can be very useful when searching through all objects on a page
    Dim it As String
    Dim i As Integer
    Dim Ctr As Integer
    '''''''''''''''''
    'Read-only  Long
    '''''''''''''''''
    For i = 1 To ActiveWindow.Selection.SlideRange.Shapes.Count
        'No need to select the object in order to use it
        With ActiveWindow.Selection.SlideRange.Shapes(i)

        'But it is easier to watch when the object is selected
        'This next line is for demonstration purposes only.
        'It is not necessary
        ActiveWindow.Selection.SlideRange.Shapes(i).Select

        Select Case .Type

            'Type 1
            Case msoAutoShape
                it = "an AutoShape. Type : " & .Type

            'Type 2
            Case msoCallout
                it = "a Callout. Type : " & .Type

            'Type 3
            Case msoChart
                it = "a Chart. Type : " & .Type

            'Type 4
            Case msoComment
                it = "a Comment. Type : " & .Type

            'Type 5
            Case msoFreeform
                it = "a Freeform. Type : " & .Type

            'Type 6
            Case msoGroup
                it = "a Group. Type : " & .Type

            ' If it's a group them iterate thru
            ' the items and list them

                it = it & vbCrLf & "Comprised of..."
                For Ctr = 1 To .GroupItems.Count
                    it = it & vbCrLf & _
                        .GroupItems(Ctr).Name & _
                        ". Type:" & .GroupItems(Ctr).Type
                Next Ctr

            'Type 7
            Case msoEmbeddedOLEObject
                it = "an Embedded OLE Object. Type : " & .Type

            'Type 8
            Case msoFormControl
                it = "a Form Control. Type : " & .Type

            'Type 9
            Case msoLine
                it = "a Line. Type : " & .Type

            'Type 10
            Case msoLinkedOLEObject
                it = "a Linked OLE Object. Type : " & .Type
                With .LinkFormat
                    it = it & vbCrLf & "My Source: " & _
                        .SourceFullName
                End With

            'Type 11
            Case msoLinkedPicture
                it = "a Linked Picture. Type : " & .Type
                With .LinkFormat
                    it = it & vbCrLf & "My Source: " & _
                        .SourceFullName
                End With

            'Type 12
            Case msoOLEControlObject
                it = "an OLE Control Object. Type : " & .Type

            'Type 13
            Case msoPicture
                it = "a embedded picture. Type : " & .Type

            'Type 14
            Case msoPlaceholder
                it = "a text placeholder (title or regular text--" & _
                     "not a standard textbox) object." & _
                     "Type : " & .Type

            'Type 15
            Case msoTextEffect
                it = "a WordArt (Text Effect). Type : " & .Type

            'Type 16
            Case msoMedia
                it = "a Media object .. sound, etc. Type : " & .Type
                With .LinkFormat
                    it = it & vbCrLf & " My Source: " & _
                    .SourceFullName
                End With

            'Type 17
            Case msoTextBox
                it = "a Text Box."

            'Type 18 = msoScriptAnchor, not defined in PPT pre-2000 so we use the numeric value
            'Case msoScriptAnchor
            Case 18
                it = " a ScriptAnchor. Type : " & .Type

            'Type 19 = msoTable, not defined in PPT pre-2000 so we use the numeric value
            'Case msoTable
            Case 19
                it = " a Table. Type : " & .Type

            'Type 19 = msoCanvas, not defined in PPT pre-2000 so we use the numeric value
            'Case msoCanvas
            Case 20
                it = " a Canvas. Type : " & .Type

            'Type 21 = msoDiagram, not defined in PPT pre-2000 so we use the numeric value
            'Case msoDiagram
            Case 22
                it = " a Diagram. Type : " & .Type

            'Type 22 = msoInk, not defined in PPT pre-2000 so we use the numeric value
            'Case msoInk
            Case 22
                it = " an Ink shape. Type : " & .Type

            'Type 23 = msoInkComment, not defined in PPT pre-2000 so we use the numeric value
            'Case msoInkComment
            Case 23
                it = " an InkComment. Type : " & .Type


            'Type -2
            Case msoShapeTypeMixed
                it = "a Mixed object (whatever that might be)." & _
                     "Type : " & .Type

            'Just in case
            Case Else
                it = "a mystery!? An undocumented object type?" & _
                        " Haven't found one of these yet!"
        End Select

        MsgBox ("I'm " & it)
        End With
    Next i
End Sub

作者: willson_62   发布时间: 2010-09-23

这段代码检索的是对象类型,不是对象索引号啊!

作者: laose   发布时间: 2010-09-24

楼上说得对,现在我还没有找索引号的对应属性,急等!

作者: willson_62   发布时间: 2010-09-25