Blank line after deleting contentControl in word

前端 未结 1 1898
时光取名叫无心
时光取名叫无心 2021-01-25 03:26

I\'m trying to write in a word document via VB.net and for this I\'m using contentControls in my Word Document but sometimes I have to delete a contentCont

1条回答
  •  攒了一身酷
    2021-01-25 04:08

    I will give you some tips based on VBA which I hope you could easily convert to vb.net and your solution.

    You need to cover complete range of ContentControl including beginning and end of the object. You could do it in this way (VBA code for first CC in activedocument):

    With ActiveDocument.ContentControls(1)
        'just to make a presentation- let's select range to be deleted
        ActiveDocument.Range(.Range.Start - 1, .Range.End + 2).Select
        'and we delete selection
        Selection.Delete
    End With
    

    Obviously you could combine .Select and .Delete lines into one to avoid selection in this way:

    With.... and so on
        ActiveDocument.Range(.Range.Start - 1, .Range.End + 2).Delete
    End with
    

    0 讨论(0)
提交回复
热议问题