vba 从 Word 文档中删除第一行处理它并在文档的开头放置一个新行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20868238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove first line from Word Document process it and put a new line at the beginning of the document
提问by Kaushik Datye
I am developing an application wherein I need to delete the first line of several word documents, merge them, merge their tables into one and place it at the top, remove all the individual tables which are merged, and then giving the merged table a name.
我正在开发一个应用程序,其中我需要删除多个 word 文档的第一行,合并它们,将它们的表合并为一个并将其放在顶部,删除所有合并的单个表,然后为合并的表命名.
I am through with almost everything except removing the first line of the individual word documents (which will be merged into one) and Putting name string to the newly generated table in the new document on top of the table. The newly generated table will be placed at the top of the new document (which is result of merging of all other documents).
除了删除单个单词文档的第一行(将合并为一个)并将名称字符串放入表格顶部新文档中新生成的表格之外,我几乎完成了所有操作。新生成的表格将放置在新文档的顶部(这是所有其他文档合并的结果)。
Can someone suggest a way to do it. If possible, deletion of first two lines will help more.
有人可以建议一种方法来做到这一点。如果可能,删除前两行会更有帮助。
回答by Kazimierz Jawor
Removing first line could mean removing first paragraph or just first line as you could see it. They are not the same therefore I provide both solution below
删除第一行可能意味着删除第一段或仅删除第一行,如您所见。它们不一样,因此我在下面提供了两种解决方案
'Remark: for ActiveDocument
'removing first paragraph
ActiveDocument.Paragraphs(1).Range.Delete
'removing first line
ActiveDocument.Range(0, 0).Select
Selection.MoveEnd wdLine
Selection.Delete