Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > How to find controls in customized document and delete them
Ask a questionAsk a question
 

AnswerHow to find controls in customized document and delete them

  • Saturday, July 04, 2009 9:43 PMStanislav Kroschenko Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    I would like to customize my document and i need to find combobox controls, check if property Text is empty or not, and if empty delete this whole line on which control is.

    I think that i need loop through all controls, check if it is control which i need, and then check text property.
    However i can't get Name property of control and i don't know how to delete whole line with my controle.

    Please help, thanks in advance

Answers

  • Wednesday, July 08, 2009 8:15 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Stanislav

    Thank you for the additional information :-)

    If the controls have been placed in the document at design time, then they cannot be deleted at run-time. Only controls inserted at run-time can be deleted from a document. The discussion in this MSDN article may be of some assistance.
    Cindy Meister, VSTO/Word MVP

All Replies

  • Monday, July 06, 2009 8:35 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Stanislav

    Which application (Word, something else)?

    Which version of the application?

    What kind of combobox controls? (If you don't know, describe the exact steps used to create them in the document.)

    Office documents can, depending on the parent application, host many different types (technologies) of controls. Before we can tell you what you need in the object model we require this additional information.
    Cindy Meister, VSTO/Word MVP
  • Tuesday, July 07, 2009 11:34 PMStanislav Kroschenko Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Cindy

    I'm customizing a document of Word 2007 application with VSTO 3.0.
    I am using the latest kind of combobox from this class Microsoft.Office.Tools.Word.ComboBoxContentControl.

    Thanks

  • Wednesday, July 08, 2009 8:15 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Stanislav

    Thank you for the additional information :-)

    If the controls have been placed in the document at design time, then they cannot be deleted at run-time. Only controls inserted at run-time can be deleted from a document. The discussion in this MSDN article may be of some assistance.
    Cindy Meister, VSTO/Word MVP
  • Wednesday, July 08, 2009 5:17 PMStanislav Kroschenko Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks, this article really helped me.