VBA Powerpoint-修改类别名称

VBA Powerpoint-修改类别名称,vba,charts,powerpoint,axis,categories,Vba,Charts,Powerpoint,Axis,Categories,我试图用下面的代码修改VBA powerpoint中现有图表的类别名称,但类别名称将从图表中删除 Dim mCatArray() As String lngSeries = 0 Dim testvar As Variant 'Get the existing category names in an Array 'oSh = Shape element For Each testvar In oSh.Chart.Axes(xlCategory).CategoryNames strIn

我试图用下面的代码修改VBA powerpoint中现有图表的类别名称,但类别名称将从图表中删除

Dim mCatArray() As String
lngSeries = 0
Dim testvar As Variant

'Get the existing category names in an Array
'oSh = Shape element
For Each testvar In oSh.Chart.Axes(xlCategory).CategoryNames
    strIn = ProperCaps(testvar & "", objRegex)
    ReDim Preserve mCatArray(lngSeries)

    'Do my changes and insert the category name in the Array
    mCatArray(lngSeries) = strIn

    lngSeries = lngSeries + 1
Next

'Assign the Changed Category array back - METHOD 1
For lngSeries = 1 To .Chart.SeriesCollection.Count
   oSh.Chart.SeriesCollection(lngSeries).XValues = mCatArray
Next

'Assign the Changed Category array back - METHOD 2
   oSh.Chart.Axes(xlCategory).CategoryNames = mCatArray

这两种方法似乎都没有帮助。非常感谢您的帮助。

您能提供更多信息吗?您试图将类别从和更改为什么,为什么不能在图表的源数据中更改它们?你也应该声明你的变量,在你的问题中只包括相关的代码(见“)。嗨,我正试图把类别名称改成一个合适的大小写句子。无论如何。我能够在字符串数组中检索类别名称并对其进行更改,但我很难将它们重新分配给类别轴。所以最后一行(oSh.Chart.Axes(xlCategory.CategoryNames=mCatArray)似乎不起作用。它似乎把这一类别全部删除了。mCatArray是先前检索到的数组。希望这能说明问题。谢谢