Accessing a method in another worksheet class? RRS feed

  • Question

  • In C#, I have a method in one worksheet and I'm trying to call the method from another worksheet's code. What is the easiest way to do this? I set the method to public but I can't figure out how to access it...
    Sunday, July 29, 2012 7:15 PM


  • Hi,

    Thanks for posting in the MSDN Forum.

    As far as I know, you can use the Globals class. For instance, add a public void Sheet2Method() to the Sheet2, and you can call it in the Sheet1 class in accordance with the following code

    namespace ExcelWorkbook1
       public partial class Sheet1
           private void Sheet1_Startup(object sender, System.EventArgs e)
           private void Sheet1_Shutdown(object sender, System.EventArgs e)

    Hope this can help you.

    Best Regards

    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 30, 2012 7:29 AM