Vba 如何检查图表是否为折线图?

Vba 如何检查图表是否为折线图?,vba,powerpoint,Vba,Powerpoint,我试图检查所选形状是否为图表,然后检查它是否为折线图 我的尝试: Sub ChartSmooth(ByVal control As IRibbonControl) Dim activeShape As Shape 'Determine Which Shape is Active If ActiveWindow.Selection.Type = ppSelectionShapes Then 'Loop in case multiples shapes selected Dim shp

我试图检查所选形状是否为图表,然后检查它是否为折线图

我的尝试:

Sub ChartSmooth(ByVal control As IRibbonControl)

Dim activeShape As Shape

'Determine Which Shape is Active
If ActiveWindow.Selection.Type = ppSelectionShapes Then
'Loop in case multiples shapes selected
    Dim shp As Shape
    For Each shp In ActiveWindow.Selection.ShapeRange
         Set activeShape = shp ' First shape selected
         Exit For
    Next

'Now, reformat the selected shape if it is a chart
    With activeShape
        If .HasChart Then
            If .ChartType = xlLine Then
                MsgBox "True" ' I will eventually put some code here to do something
            End If
        End If
    End With ' activeShape

End If

ActiveWindow.Selection.Unselect

End Sub

我做错了什么?

只需在前面添加.Chart即可。ChartType:

If .HasChart Then
    If .Chart.ChartType = xlLine Then