none
CheckBox and Microsoft.Office.Tools.Excel.Controls RRS feed

  • Question

  • Bonjour,

    Je développe actuellement un add-in pour Excel. Je récupère des éléments dans une base de données et je les affiche dans un fichier excel. Ce que j'aimerais pouvoir faire c'est ajouter une checkbox a coté de chaque ligne pour que l'utilisateur puisse choisir les lignes qu'il veut, pour pouvoir les traiter ensuite.

    Le problème c'est que j'ai bien Microsoft.Office.Tools.Excel dans les références (version 10.0) mais je n'ai pas accès à Microsoft.Office.Tools.Excel.Controls. Or il me semble que c'est l'unique moyen d'insérer une checkbox dans la feuille excel.

    Si vous avez déjà rencontré ce problème et si vous pouviez m'aider je vous en serais très reconnaissant.

    Viaudv

    Tuesday, April 22, 2014 4:21 PM

Answers

  • Hi Viaudv,

    Which version of Visual Studio are you using? If you are using Visual Studio 2008, “Microsoft.Office.Tools.Excel.Controls" class exists in the Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll).

    You can get more detail about the class reference based on the Visual Studio you are using like figure below:


    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 23, 2014 6:58 AM
    Moderator
  • Hi Viaudv,

    If you are using Visual Studio 2010, you need to add the "Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)" for reference like figure below:

    And here is a sample to add the check box into A1 cell for your reference:

      Microsoft.Office.Interop.Excel.Worksheet workSheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
                Microsoft.Office.Tools.Excel.Worksheet workSheet1;
                workSheet1 = Globals.Factory.GetVstoObject(workSheet);
    
                Microsoft.Office.Tools.Excel.Controls.CheckBox cb = workSheet1.Controls.AddCheckBox(workSheet1.Range["A1"], "cb1");
                cb.Checked = true;

    You can get more detail form link below:
    Adding Controls to Office Documents at Run Time

    Microsoft.Office.Tools.Excel.Controls

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 23, 2014 8:41 AM
    Moderator

All replies

  • Hi,

    I am currently developping an excel add-in. I get data from a SQL Server database and show it in my excel sheet.

    What I'd like to do is put a checkbox besides each row to allow the user to choose the rows he wants to send.

    Problem is I already referenced "Microsoft.Office.Tools.Excel" (10.0 version) but I can't reach the "Microsoft.Office.Tools.Excel.Controls" library. Although it seems to me it is the only way to add checkboxes in the excel sheet.

    If you have already encountered this problem and if you can help me dealing with it I would be very grateful.

    Viaudv

    Tuesday, April 22, 2014 4:26 PM
  • Hi Viaudv,

    Which version of Visual Studio are you using? If you are using Visual Studio 2008, “Microsoft.Office.Tools.Excel.Controls" class exists in the Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll).

    You can get more detail about the class reference based on the Visual Studio you are using like figure below:


    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 23, 2014 6:58 AM
    Moderator
  • I am currently using Visual Studio 2010.

    I actually saw Microsoft.Office.Tools.Excel.v9.0.dll but when I refer to it, Visual asks me to add also Microsoft.Office.Tools.v9.0.dll   and then it interfers with Microsoft.Office.Interop.Excel.dll .

    Isn't there a 2010 version Microsoft.Office.Tools.Excel.Controls.dll library?

    Wednesday, April 23, 2014 7:10 AM
  • Hi Viaudv,

    If you are using Visual Studio 2010, you need to add the "Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)" for reference like figure below:

    And here is a sample to add the check box into A1 cell for your reference:

      Microsoft.Office.Interop.Excel.Worksheet workSheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
                Microsoft.Office.Tools.Excel.Worksheet workSheet1;
                workSheet1 = Globals.Factory.GetVstoObject(workSheet);
    
                Microsoft.Office.Tools.Excel.Controls.CheckBox cb = workSheet1.Controls.AddCheckBox(workSheet1.Range["A1"], "cb1");
                cb.Checked = true;

    You can get more detail form link below:
    Adding Controls to Office Documents at Run Time

    Microsoft.Office.Tools.Excel.Controls

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 23, 2014 8:41 AM
    Moderator
  • Thank you very much, I think this is exactly my problem!

    Just another question: do you have any direct link for downloading "microsoft.office.tools.excel.v4.0.utilities.dll" or do you know how to deploy the "microsoft.office.tools.excel.v4.0.utilities.dll.deploy"?

    Wednesday, April 23, 2014 9:56 AM
  • It's okay, I just had tu delete the ".deploy" at the end to change the extension and it works with your code when I add the reference!

    Thank you very much again Fei!

    Best regards,

    Viaudv

    Wednesday, April 23, 2014 10:06 AM
  • Hi Viaudv,

    We don't need to download the dll separatly, these tools are installed by default when you install one of the Visual Studio editions in the previous list. If you customize the Visual Studio installation by specifying which features to install, specify Microsoft Office Developer Tools during setup to install the tools.

    You can get more detail from link below:
    Configuring a Computer to Develop Office Solutions

    Also you may interest in the link below:
    Deploying an Office Solution

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 24, 2014 9:17 AM
    Moderator