我有一些代码可以根据选择自动检测某些文本并将其放在用户表单上。
我面临的问题是删除结尾的段落标记。 (请参见下图):
我尝试了以下和其他变体,但无法删除结尾的段落标记:
Dim theText As String
theText = Replace(Selection, "^p", "")
最后,我知道我可以使用Left(Selection,Len(Selection)-1)
,但是如果段落标记不存在,这将失败。
答案 0 :(得分:0)
要获取Word中的段落,请使用以下2个选项之一(第一个选项适用于OP):
theText = Replace(Selection, ChrW$(13), "")
theText = Replace(Selection, ChrW$(244), "")
答案 1 :(得分:0)
如上面的注释中所述,这是解决方案:
Dim theText As String
theText = Replace(Selection, Chr(13), "")