PDA

View Full Version : Error when trying to access .ChartData.Workbook for Map Charts (ChartType=xlRegionMap



mbraun
10-16-2023, 10:23 AM
Excel macro that loops through slides of a PowerPoint presentation and changes the data for numerous charts.
Macro works perfectly fine until it comes across a shape where .Chart.ChartType=xlRegionMap
Code where I get the error: Set wbk = Sh.Chart.ChartData.Workbook
Again, this line works fine for every other type of chart except a region map. Anyone know why this is, and have a workaround?
Any help is much appreciated!

Aussiebear
10-16-2023, 03:00 PM
Excel is different from Powerpoint in its naming convention. In Excel vba you need to refer to the workbook first, then the chart object

mbraun
10-16-2023, 08:59 PM
Excel is different from Powerpoint in its naming convention. In Excel vba you need to refer to the workbook first, then the chart object

Thank you for the response. I get that. My point is, what I have for code currently works for every single chart type EXCEPT a RegionMap. So it seems my syntax is fine, but I just can't seem to figure out why it won't work for that one chart type.

mancubus
10-19-2023, 12:22 AM
I think this is yours:
https://www.reddit.com/r/vba/comments/179e14h/error_when_trying_to_access_chartdataworkbook_for/

another topic from reddit:
https://www.reddit.com/r/vba/comments/14yv9st/error_when_trying_to_access_chartdataworkbook_for/

you may consider Khazahk's reply:

The region map probably doesn’t have the “chartdata”property.
Check the object library and see what makes RegionMaps different. Could be a property called “RegionData” and the. Perhaps you can call the workbook from there.
You would simply throw in an If statement. If Charttype = regionmap then do it this way else do it the other way end if.

or you may include "On Error Resume Next" in your code and do the RegionMap stuff manually.