Consulting

Results 1 to 4 of 4

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

  1. #1
    VBAX Newbie
    Joined
    Oct 2023
    Posts
    3
    Location

    Error when trying to access .ChartData.Workbook for Map Charts (ChartType=xlRegionMap

    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!

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Excel is different from Powerpoint in its naming convention. In Excel vba you need to refer to the workbook first, then the chart object
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Newbie
    Joined
    Oct 2023
    Posts
    3
    Location
    Quote Originally Posted by Aussiebear View Post
    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.

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    I think this is yours:
    https://www.reddit.com/r/vba/comment...aworkbook_for/

    another topic from reddit:
    https://www.reddit.com/r/vba/comment...aworkbook_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.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •