首页 > 解决方案 > Powerpoint VBA - .Tags.Add 上的语法错误

问题描述

我的代码如下(引用此答案的标签构建):

Public Sub LinkToAddInfo(currentSlide As Long, boxName As String, addDisplay As Long, addName As String, addNumber As Long)

    Dim oShape As Shape
    Set oShape = ActivePresentation.Slides(currentSlide).Shapes.AddShape(msoShapeRoundedRectangle, 640, 470, 71, 27)

    With oShape
        .Fill.ForeColor.RGB = RGB(191, 191, 191)
        .Fill.Transparency = 0
        .Name = boxName
        .Tags.Add("Nametag",ActivePresentation.Slides(addNumber).Name)

        With .ActionSettings(ppMouseClick)
            .Action = ppActionHyperlink
            .Hyperlink.SubAddress = addNumber
        End With

    End With ' Square itself

End Sub

一切正常,但该.Tags.Add("Nametag",ActivePresentation.Slides(addNumber).Name)行引发语法错误。即使我用硬编码字符串(如"test".

为什么是这样?

标签: vbapowerpoint

解决方案


解决了。只需要将其更改为:

.Tags.Add "Nametag", ActivePresentation.Slides(addNumber).Name

推荐阅读