当形状位于页面外部时,如何使用VBA在Publisher中获取形状?

当形状位于页面外部时,如何使用VBA在Publisher中获取形状?,vba,publisher,Vba,Publisher,我有一个外部进程,它向发布者页面添加了许多形状。 遗憾的是,有些形状被放在了页面之外 此形状不在该页的形状集合中。有人知道我在哪里能买到吗 下面是复制问题的示例代码: Sub main() Dim oPage As Page Dim oTable As Table Dim oBox As Shape Dim oLine As Shape Set oPage = ActiveDocument.Pages(1) Set oBox = oPage.S

我有一个外部进程,它向发布者页面添加了许多形状。 遗憾的是,有些形状被放在了页面之外

此形状不在该页的形状集合中。有人知道我在哪里能买到吗

下面是复制问题的示例代码:

Sub main()
    Dim oPage As Page
    Dim oTable As Table
    Dim oBox As Shape
    Dim oLine As Shape


    Set oPage = ActiveDocument.Pages(1)
    Set oBox = oPage.Shapes.AddTable(2, 1, -150, 50, 120, 30, False)
    oBox.Name = "Pepe"

    Set oBox = oPage.Shapes.AddTable(2, 1, 350, 150, 120, 30, False)
    oBox.Name = "Pepa"

    Set oLine = oPage.Shapes.AddConnector(msoConnectorElbow, 0, 0, 100, 100)

    With oLine.ConnectorFormat
        .BeginConnect oPage.Shapes.Item("Pepe"), 1 'here are the error!!!
        .EndConnect oPage.Shapes.Item("Pepa"), 1
    End With

End Sub
我想要的是得到Shapes.itempee,即使它不在页面左侧-150。页面中没有的形状在哪里

提前谢谢

天使。

我找到了

文档下有一个草稿区域,其中包含页面外的所有形状

因此,我可以使用以下内容修改代码:

Sub main()
    Dim oPage As Page
    Dim oTable As Table
    Dim oBox As Shape
    Dim oLine As Shape
    Dim oScratch As ScratchArea


    Set oPage = ActiveDocument.Pages(1)
    Set oScratch = ActiveDocument.ScratchArea
    Set oBox = oPage.Shapes.AddTable(2, 1, -150, 50, 120, 30, False)
    oBox.Name = "Pepe"
    oBox.Tags.Add "Cuadro", "Pepe"

    Set oBox = oPage.Shapes.AddTable(2, 1, 350, 150, 120, 30, False)
    oBox.Name = "Pepa"
    oBox.Tags.Add "Cuadro", "Pepa"

    Set oLine = oPage.Shapes.AddConnector(msoConnectorElbow, 0, 0, 100, 100)

        With oLine.ConnectorFormat
            On Error Resume Next
            .BeginConnect oPage.Shapes.Item("Pepe"), 1
            If Err.Number <> 0 Then
                Err.Clear
                .BeginConnect oScratch.Shapes.Item("Pepe"), 1
            End If
            .EndConnect oPage.Shapes.Item("Pepa"), 1
            If Err.Number <> 0 Then
                Err.Clear
                .EndConnect oScratch.Shapes.Item("Pepa"), 1
            End If
            On Error GoTo 0
        End With

    End Sub
谢谢

可能重复的