删除内容控件所在的行 [英] Removing the line where a content control is

查看:145
本文介绍了删除内容控件所在的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要删除内容控件所在的行.

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:

删除word中的contentControl后出现空白行

如何删除整个使用vba的单词文档行

删除ms word 2007中的某些行

如何删除按行发布"?

编辑

我之前显示的所有文本都在表格的一行中.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆