Develop an excel add-in that modifies cells in active worksheet RRS feed

  • Question

  • I am developping an add-in using the vsto add-in template in and I'll like to know how to get access to the cells within a spread sheet as using the document spreadsheet template it is basically using the range method.
    Monday, April 25, 2011 11:58 PM


All replies

  • Hi,


    maybe have a look at this sample:


    Working with Cells:


    In a VSTO Project, the Application Object is accessible via Globals.ThisAddin.Application

    Hope this helps,

    Greets - Helmut

    Helmut Obertanner [] []
    Tuesday, April 26, 2011 9:53 AM
  • Thanks for the help. It seems intellisense does not work to well with vsto in some scenarios. Now I need to know how to copy values into a different sheet in the same workbook, but what if my file has only one sheet. I tried to figure a way to create a new sheet butI always get null refrence exception. Below is the only funcational parts of my code. It works 90% of cases that I need it for. Sorry for the bad structure and naming convention.

    Dim rng As Excel.Range = Globals.ThisAddIn.Application.ActiveSheet.Range("A1")

                Dim tapeRng As Excel.Range = Globals.ThisAddIn.Application.Sheets("Sheet2").Range("A1")
                MsgBox("TEST"MsgBoxStyle.Critical, rng.ToString)
                tapeRng.Value2 = rng.Value2

            Catch ex As Exception

            End Try


    Sunday, June 12, 2011 2:21 AM