如何隐藏 Microsoft Word 中特殊字符之间的文本?
How I can hide text that is beetween special characters in Microsoft Word?
我正在尝试制作一个宏,但我不知道从哪里开始,我想在特殊字符之间隐藏一些文本,例如:
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ (including "space" char)
例如,如果我有这样的文档:
::00-58-96::Hello there
::00-58-97::This is a test
::00-58-98::Nothing else
::00-58-99::Good bye !
我想在宏执行后得到这个:
Hello there
This is a test
Nothing else
Good bye !
之间的文字
:: ::
已淘汰(包括:::)
另一个例子:
>>>some%text_here>>>This is another example
>>>some%text"here>>>Thank you for reading
>>>some%text@here>>>I hope you will have
>>>some&text²here>>>A great day
输出将是:
This is another example
Thank you for reading
I hope you will have
A great day
起初我想使用 "Find and replace text" 功能,但我认为对于这个来说太复杂了。
任何提示都会很有帮助。
谢谢!
这将完成:
注意:它将删除不需要的文本。不隐藏。
Sub tst()
ActiveDocument.Range.Select ' You can remove this line and run macro after selecting the text in which you want the replacement. This line will select the entire document.
With Selection.Find
.MatchWildcards = True
.Text = "::*::"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With
End Sub
专业版:如果未按预期执行,Cntrl + Z
将努力撤消此操作。
为此您不需要 VBA - 您只需要一个 通配符 Find/Replace,其中:
查找 = ([!"#$%&'()*+,-./:;<=>\?@[\]^94_`{|}~]{2,})*\ 1
然后,根据您是要删除还是只是隐藏找到的内容,使用:
替换 = 无
或
替换=^&
分别使用 'Hidden' 字体 属性。
当然可以把上面的录制成宏
我正在尝试制作一个宏,但我不知道从哪里开始,我想在特殊字符之间隐藏一些文本,例如:
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ (including "space" char)
例如,如果我有这样的文档:
::00-58-96::Hello there
::00-58-97::This is a test
::00-58-98::Nothing else
::00-58-99::Good bye !
我想在宏执行后得到这个:
Hello there
This is a test
Nothing else
Good bye !
之间的文字
:: ::
已淘汰(包括:::)
另一个例子:
>>>some%text_here>>>This is another example
>>>some%text"here>>>Thank you for reading
>>>some%text@here>>>I hope you will have
>>>some&text²here>>>A great day
输出将是:
This is another example
Thank you for reading
I hope you will have
A great day
起初我想使用 "Find and replace text" 功能,但我认为对于这个来说太复杂了。
任何提示都会很有帮助。
谢谢!
这将完成:
注意:它将删除不需要的文本。不隐藏。
Sub tst()
ActiveDocument.Range.Select ' You can remove this line and run macro after selecting the text in which you want the replacement. This line will select the entire document.
With Selection.Find
.MatchWildcards = True
.Text = "::*::"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With
End Sub
专业版:如果未按预期执行,Cntrl + Z
将努力撤消此操作。
为此您不需要 VBA - 您只需要一个 通配符 Find/Replace,其中:
查找 = ([!"#$%&'()*+,-./:;<=>\?@[\]^94_`{|}~]{2,})*\ 1
然后,根据您是要删除还是只是隐藏找到的内容,使用:
替换 = 无
或
替换=^&
分别使用 'Hidden' 字体 属性。
当然可以把上面的录制成宏