none
How to set Selection.Formula property of Excel.Shape RRS feed

  • Question

  • Hi ,
        I want to know how to set a Selection.Formula property of Excel.Shape from c#
        I have tried much ways, but it didn't works.
        For example, I have tried
        (Excel.Range)xlShape).Formula = "A2:B5"
    and it tells me "failed to convert"..

        anyone help me, please.

    Tuesday, March 17, 2009 9:34 AM

All replies

  • Hi ,

    Please tell us which version of Excel is involved? Also your VSTO version?

    In above code, you are going to convert a Shape object to a Range object, it is not possible in Excel, they are different objects, you may misunderstand the Excel Object Model, please check this map of Excel Object Model, you may more clear with the concept.
    http://msdn.microsoft.com/en-us/library/bb332345.aspx

    Or you could tell us the goal you expect to achieve may be we could give you some suggestion.


    Thanks



    We have published a VSTO FAQ recently, you can view them from the entry thread http://social.msdn.microsoft.com/Forums/en/vsto/thread/31b1ffbf-117b-4e8f-ad38-71614437df59. If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Monday, March 23, 2009 8:57 AM
  • The solution is:

    shape.DrawingObject.Formula = "=sum(...)";

    Thursday, February 13, 2014 12:43 PM