删除内容控件所在的行 [英] Removing the line where a content control is
问题描述
我要删除内容控件所在的行.
I want to remove a line where my content control is.
当前文档具有以下文本:
Currently the document has this following text:
t1
t2
Status: Draft
Valid from: 01.01.2012
Valid for: All Emplyoees
Created by: a
Released by: <content control goes here>.
我有一个变量controlff
,它是对控件的引用.不管我如何获得范围,我总是以删除全文为结尾.
I have a variable controlff
which is a reference to the control. No matter how I get a range from it I always ended up by deleting the full text.
这其他问题对我的帮助不大:
This other questions didn't quite help me:
如何删除按行发布"?
编辑
我之前显示的所有文本都在表格的一行中.
All the text that I showed before is inside of a single row on a table.
推荐答案
这是一个如何在表中执行此操作的小示例.首先获取内容控件,将所选内容扩展到表格单元格中的前一行,然后删除所选内容.
Here is a small example how to do this in a table. First get the Content Control, Exctend the selection to the previous line in the table cell and delete the selection.
Sub test()
Dim rng As Range
'Get your Content Control here based on your variable reference
Set rng = ActiveDocument.ContentControls(1).Range
rng.Select
'Move outside the Content Control
Selection.MoveRight wdCharacter
Selection.MoveRight wdCharacter
'Select Line Up
Selection.MoveUp Unit:=wdParagraph, Count:=1, Extend:=wdExtend
'Include the paragraph from previous line
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
'And ... Delete the selected area
Selection.Delete
End Sub
希望有帮助
这篇关于删除内容控件所在的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!