none
custom properties Excel RRS feed

  • Question

  • I am using VB.NET to develop a COM addin for Excel.   I am able to create new custom properties for Excel worksheets, then store and retrieve data by them. 

    I would like to do the same for an Excel chart, but my program is not working.   Visual Studio will compile and run this, but when it runs, it doesn't create or store data.   Each "If" statement registers true for the first "i", but no value is stored.

    Dim thisChart as Excel.Chart = Globals.Addin.Application.ActiveChart
    
    thisChart.CustomProperties.Add("StoredInfo1")
    
    thisChart.CustomProperties.Add("StoredInfo2")
    
    
    For i as integer = 1 to thisChart.CustomProperties.Count
    
    If thisChart.CustomProperties(i).Name = "StoredInfo1" Then
    thisChart.CustomProperties(i).Value = "Stored information 1"
    
    If thisChart.CustomProperties(i).Name = "StoredInfo2" Then
    thisChart.CustomProperties(i).Value = "Stored information 2"
    
    Next

    Is it possible to create and use custom properties for Excel.Charts?  If so, what am I doing wrong?

    Thank you,


    Gina



    • Edited by Gina1111 Thursday, September 18, 2014 6:48 PM
    Thursday, September 18, 2014 6:46 PM

Answers

  • Hi Gina,

    >>Is it possible to create and use custom properties for Excel.Charts?  If so, what am I doing wrong?<<

    No, it is impossible.

    As far as I know, the CustomProperties is a collection of CustomProperty objects that represent additional information. The information can be used as metadata for XML.

    We can get CustomProperties property of the Worksheet object to return a CustomProperties collection.

    And as far as I test, this collection is not availbe for the chartsheet and chart object(We can active the chart and use activesheet to refer to the chartsheet).

    Would you mind sharing with us the detail information how you make the code complile successfully?

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Michal Krzych Friday, September 19, 2014 7:24 AM
    • Marked as answer by Gina1111 Friday, September 19, 2014 12:49 PM
    Friday, September 19, 2014 6:04 AM
    Moderator

All replies

  • Hi Gina,

    >>Is it possible to create and use custom properties for Excel.Charts?  If so, what am I doing wrong?<<

    No, it is impossible.

    As far as I know, the CustomProperties is a collection of CustomProperty objects that represent additional information. The information can be used as metadata for XML.

    We can get CustomProperties property of the Worksheet object to return a CustomProperties collection.

    And as far as I test, this collection is not availbe for the chartsheet and chart object(We can active the chart and use activesheet to refer to the chartsheet).

    Would you mind sharing with us the detail information how you make the code complile successfully?

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Michal Krzych Friday, September 19, 2014 7:24 AM
    • Marked as answer by Gina1111 Friday, September 19, 2014 12:49 PM
    Friday, September 19, 2014 6:04 AM
    Moderator
  • I had done what you propose, which is to imbed the chart in a new worksheet, then refer to the custom properties of the worksheet.   This works fine.

    Thank you,

    Gina


    Gina

    Friday, September 19, 2014 12:50 PM