0

我的 PowerPoint 幻灯片上有一个包含八张图片的库。根据用户表单输入,通过在原始图像名称后添加“1”或“2”来复制和重命名某些组件,以便它们可以区分。然后我想对新图像进行分组(我正在从组件图像构建一个项目)。我能够复制图像并将它们正确排列,但我无法对它们进行分组。请注意,我并不总是对相同数量的项目进行分组,它取决于用户输入。

我收到错误“形状(未知成员):无效请求。要选择形状,其视图必须处于活动状态。”

我搜索并尝试从帮助论坛中实施几种策略,但结果是空的。

请帮忙!!!-凯文

下面的部分代码因为它很长,但这是我的第一个问题出现的地方:

Dim Cargo As Shape, Cargo_Dup as Shape, Chemical as Shape, Chemical_Dup as Shape
Set Cargo = ActivePresentation.Slides(2).Shapes("Cargo")
Set Chemical = ActivePresentation.Slides(2).Shapes("Chemical")
Cargo.Name = "Cargo"
Chemical.Name = "Chemical"

With ActivePresentation
Set Cargo_Dup = ActivePresentation.Slides(2).Shapes("Cargo")
    With Cargo_Dup.Duplicate
        .Name = "Cargo_1st"
        .Left = 0
        .Top = 540
    End With
'CHEMICAL
If Input1 = "Chemical" Then
    Set Chemical_Dup = ActivePresentation.Slides(2).Shapes("Chemical")
        With Chemical_Dup.Duplicate
            .Name = "Chemical" & 1
            .Left = 36.74352
            .Top = 540 + 0.36
        End With
   '''''WHERE PROBLEM ARISES'''''
    ActivePresentation.Slides(2).Shapes("Cargo_1st").Select
    ActivePresentation.Slides(2).Shapes("Chemical1").Select msoFalse
    Set Vehicle = ActiveWindow.Selection.ShapeRange.Group
    Vehicle.Name = "Vehicle"
'Elseif with a bunch for options where addition grouping occurs
4

1 回答 1

0

我需要某种键盘宏来为我输入:

除非绝对必须,否则永远不要选择任何东西。你几乎从来没有绝对必须这样做。

您正在询问如何使视图处于活动状态,以便您可以选择某些内容。我认为这是错误的问题。
知道如何使用形状而不必选择它们会更有用。对形状进行分组而不选择它们有点棘手,但可以做到。

这是一个示例,说明您可以如何进行此操作:

Sub GroupWithoutSelecting()

    Dim oSl As Slide
    Dim oSh As Shape
    Dim aShapes() As String

    Set oSl = ActivePresentation.Slides(2) ' or whichever slide you like
    ReDim aShapes(1 To 1)

    With oSl
        For Each oSh In .Shapes
            If oSh.Type <> msoPlaceholder Then ' can't group placeholders

                ' Substitute the real condition you want to use
                ' for selecting shapes to be grouped here
                If oSh.Type = msoAutoShape Then
                    ' add it to the array
                    aShapes(UBound(aShapes)) = oSh.Name
                    ReDim Preserve aShapes(1 To UBound(aShapes) + 1)
                End If

            End If
        Next

        ' eliminate the last (empty) element in the array
        ReDim Preserve aShapes(1 To UBound(aShapes) - 1)

        ' Create a shaperange from the array members and group the shaperange
        .Shapes.Range(aShapes).Group

    End With ' oSl

End Sub
于 2014-12-05T16:27:04.647 回答