none
Content Control Delete RRS feed

  • Question

  • Hi all,

    i am hoping someone can help. I have a master document that contains several contentcontrols and each contentcontrol has a list with at least one bullet point. For e.g

    ContentControl1

    • Item1

    I want to programatically delete the contentcontrol and its content. I am able to do that except that when I do it that was the bullet point is left behind. ie.

    •  

    is still visible on the page.

    How can I remove the contentcontrol and all is content as well not have that bullet point float around.

    Thanks in advance.

    Ashwin


    Ashwin

    Thursday, February 9, 2012 12:47 AM

Answers

  • Hi Ashwin

    Are the bullet points the only thing in the content control?

    When you remove the content control and its contents, is there an empty paragraph ("line") where the content control used to be, or is this merging into surrounding text? If it's an empty paragraph ("line") do you need it?

    What I'm guessing is happening is that you are getting an empty paragraph and it's simply retaining the formatting. Deleting the paragraph would solve the problem, as would re-formatting it if you want ot retain it.


    Cindy Meister, VSTO/Word MVP

    • Marked as answer by Bruce Song Thursday, February 23, 2012 10:04 AM
    Thursday, February 9, 2012 3:29 PM
    Moderator
  • Hello,

    Try this:

    Range rangeOfContentControl = contentControl.Range;
    contentControl.Delete(true);
    rangeOfContentControl.ListFormat.RemoveNumbers();

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    • Marked as answer by Bruce Song Thursday, February 23, 2012 10:04 AM
    Friday, February 10, 2012 6:49 AM

All replies

  • Hi Ashwin

    Are the bullet points the only thing in the content control?

    When you remove the content control and its contents, is there an empty paragraph ("line") where the content control used to be, or is this merging into surrounding text? If it's an empty paragraph ("line") do you need it?

    What I'm guessing is happening is that you are getting an empty paragraph and it's simply retaining the formatting. Deleting the paragraph would solve the problem, as would re-formatting it if you want ot retain it.


    Cindy Meister, VSTO/Word MVP

    • Marked as answer by Bruce Song Thursday, February 23, 2012 10:04 AM
    Thursday, February 9, 2012 3:29 PM
    Moderator
  • Hello,

    Try this:

    Range rangeOfContentControl = contentControl.Range;
    contentControl.Delete(true);
    rangeOfContentControl.ListFormat.RemoveNumbers();

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    • Marked as answer by Bruce Song Thursday, February 23, 2012 10:04 AM
    Friday, February 10, 2012 6:49 AM