none
Convert excel address to range using interop

    Question

  • I have cell address that user can input like $A$2:$E$73. How can I get range object from this. I have tried looking at the interface definitions but cannot find anything. I'm using excel interop dll but not VSTO.  I can parse that text, but...

    On a side note, I had to move out of VSTO because our customers did not want to install VSTO runtime. can't help and so, I'm moving on with shared addin and the shim approach.

    Thanks
    Chandra.
    Tuesday, December 29, 2009 5:45 PM

Answers

  • Given you have get the worksheet object, you can get the range object through code:
    Microsoft.Office.Interop.Excel.Range yourRange = worksheet.Range["A2", "E73"];

    -Forrest
    • Marked as answer by Bessie Zhao Thursday, December 31, 2009 6:53 AM
    Wednesday, December 30, 2009 2:28 AM

All replies

  • Given you have get the worksheet object, you can get the range object through code:
    Microsoft.Office.Interop.Excel.Range yourRange = worksheet.Range["A2", "E73"];

    -Forrest
    • Marked as answer by Bessie Zhao Thursday, December 31, 2009 6:53 AM
    Wednesday, December 30, 2009 2:28 AM
  • Hello Chandra,

    Forrrest's suggest should fix the problem you are facing. If you have any further question how to get the worksheet object, please feel free to let us know.

    It seems that you are working with a Shared Add-in. This forum is not the proper place for a issue about Shared Add-in. For Shared Add-in, the best place for this is office.developer.com.add_ins newsgroup: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.office.developer.com.add_ins&lang=en&cr=US. You also could refer to this forum's PLEASE READ FIRST to learn more about VSTO technology.

    Best regards,
    Bessie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, December 31, 2009 6:52 AM
  • Thanks. I'll look at the shared addin forum from next time.

    I understand worksheet.Range[...] will work, but I was looking for some function which can replace the range function in VBA. the Range.Address returns a string and there is no function in Range which can take that address. It only works using individual cell address.


    -Chandra.
    Thursday, December 31, 2009 3:26 PM