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.

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


    We have published a VSTO FAQ recently, you can view them from the entry thread If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to
    Monday, March 23, 2009 8:57 AM
  • The solution is:

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

    Thursday, February 13, 2014 12:43 PM