VBA WORD:删除 SHIFT-ENTER 行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15986938/
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
VBA WORD: Remove SHIFT-ENTER lines
提问by JoshDG
After copying from ppt, you often get lines that look like this:
从ppt复制后,你经常会得到如下所示的行:
This is a line
and then another line
and then another
and so forth. New lines created
via SHIFT-ENTER.
Where I need it to say:
我需要它说的地方:
This is a line and then another line and then another and so forth. New lines created via SHIFT-ENTER.
这是一条线,然后是另一条线,然后是另一条线,依此类推。通过 SHIFT-ENTER 创建的新行。
New lines created by just pressing ENTER should remain as new lines.
只需按 ENTER 创建的新行应保留为新行。
采纳答案by Siddharth Rout
Shift+ Enteris nothing but ^l
Shift+Enter不过是^l
This is how Shift+ Enterlooks like
这就是Shift+ 的Enter样子
So you can either replace it manually or use the below VBA Code.
因此,您可以手动替换它或使用下面的 VBA 代码。
Non VBA Way
非 VBA 方式
- Press Ctrl+H to open the Replace dialog.
- In the "Find what" box, type
^l
. - In the "Replace with" box, type
" "
(Space without the quotes). - Click Replace All.
- 按 Ctrl+H 打开替换对话框。
- 在“查找内容”框中,键入
^l
。 - 在“替换为”框中,键入
" "
(不带引号的空格)。 - 单击全部替换。
VBA Way
VBA方式
Paste this in a module
将此粘贴到模块中
Sub Sample()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^l"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
回答by Steve Rindsberg
This page on the PPT FAQ I maintain explains the characters that PPT uses for linebreaks vs paragraph endings. It varies somewhat across versions and shape types.
我维护的 PPT FAQ 上的这个页面解释了 PPT 用于换行符和段落结尾的字符。它因版本和形状类型而有所不同。
Paragraph endings and line breaks http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm
段落结尾和换行符 http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm