Return value of a point in a series in PowerPoint VBA - vba

I need to return the value of a data point in a chart to compare it to a known value and display a data label if it is over a certain threshold in PowerPoint.
This post explains how to do it in excel, but .values doesn't appear to be in the ppt object model.
Determining the value of a point in Excel VBA
I know there is .points(i), but that doesn't seem to be able to return the actual value of the point.
Any help is appreciated.
Thanks,
Brian

This seems to work fine for me
Dim chartSeries As Series
Set chartSeries = chartShape.Chart.SeriesCollection(1)
seriesValue = chartSeries.Values(1)

Related

cannot get value from a cell in libreoffice 6.4.3.2 basic

I am new to libreoffice basic, i have experience with VBA but this libreoffice is different.
I just want to get cell value but it always return zero value to me while the actuall cell can be text or number.
Here is a partial of my simple code.
Sub test_moved()
Dim Doc As Object
'worksheet
Dim sh_village As Object
Dim sh_cbc As Object
sh_village = ThisComponent.CurrentController.getActiveSheet()
'sh_village = Doc.Sheets.getByName("VillageFinal")
'sh_village = Doc.Sheets(1)
Msgbox(sh_village.getCellrangeByName("B2").getValue())
Msgbox(sh_village.getCellrangeByName("B2").Value)
Msgbox(sh_village.getCellByPosition(1,1).Value)
msgbox("The process is completed.")
End Sub
Do we need to do prior task before start coding?
The code works correctly for numeric values. However, for strings, including strings that look like a number, it will display 0 because there is no numeric value.
What you probably want instead is:
MsgBox(sh_village.getCellRangeByName("B2").getString())
Also check out Format -> Cells -> Number to see how the data is displayed in the cell. And be on the lookout for a single quote at the front of the value in the formula bar (for example '42), because that means it is a string. Delete the quote to make it a number.
i have experience with VBA but this libreoffice is different.
Yes, LibreOffice Basic is a different language from VBA and the LibreOffice API is very different from the MS Office API. Knowing that will help you use it more effectively. If possible, avoid Option Compatible, because it won't fix most problems and will only muddy the waters.

PowerPoint VBA - extending chart data range

I am trying to create a VBA macro in PowerPoint that will extend the range of an excel embedded chart to the last row with data. How can this be achieved?
You can use "lastrow," which is expressed as an integer.
Table.LastRow
So, depending on your slide, you might say something like
ActivePresentation.Slides(3).Shapes(5).Table.lastRow
to get the last row number.

How to change data label width in an Excel chart with VBA?

I want to change a label width in Excel chart by VBA code:
set lbl = SERIES1. points(1).datalabel
msgbox lbl.width 'this is working
lbl.width = 40 ' compile error: wrong number of arguments or invalid property assignment
I can get the label width but cannot change it. What am I doing wrong?
AFAIK, the width of a chart data point label is not configurable. Even though the width can be retrieved with VBA, it's not possible to set or change it with a VBA command or property.
According to the documentation, the DataLabels.Width property is read only.
Returns the width, in points, of the object. Read-only.
Source
Excel chart labels remain stubbornly uncooperative and resist formatting attempts, be it with VBA or with the UI.
That's (unfortunately) just how Excel works.
Don't shoot the messenger.
If you want to make a difference, consider raising an idea at excel.uservoice.com
This works in Excel 2016, you'll just need to adjust the series collection and point numbers to fit your needs. ActiveChart.FullSeriesCollection(1).Points(1).DataLabel.Width = 363.314.

SeriesCollection array size in PPT VBA

I am trying to add data labels to all my series in a bar chart but the amount of series varies from chart to chart because this is a function used for many charts. So, I used a For Loop to add them, but I need to determine the size of the SeriesCollection array. Would there be a function that would do so? When I try to use .Size it gives me an error.
Below is what I tried:
With Chart
For i = 1 To .SeriesCollection.Size
.SeriesCollection(i).Points(i).HasDataLabel = True
Next i
End With
Some of the stuff in the Chart object model isn't properly hooked up to Intellisense. You'll notice that you get no suggestions when you type .SeriesCollection.
.SeriesCollection.Count will give you what you're after, I think.

Excel Interop VSTO Chart: Retrieve the chart Data Range?

I know how to set the range containing the Data (chart.SetSourceData(...))
But how can I retrieve the Chart Data range?
Does a range = chart.GetDataSource() exists ??
I cannot find it.
Help welcome,
Jean-Marie
I don't think there is a direct way. My best suggestion is to go over the series of the chart and check the Values and XValues of the series.
foreach (Series series in chart.SeriesCollection()){
Range values = series.Values;
Range xvalues = series.XValues;
}
You can then join all the ranges together and get the source data of the chart.