在Word中创建一个宏 [英] Creating a macro in Word
问题描述
嗨组,
我有一个关于创建的问题Word中的宏。
我想在Word中创建一个复制一行的宏,并在第二行中仅显示文本介于{}之间。
例如:
这是{美丽}天
成为:
这是一个{美丽的一天
< span lang ="EN-US">
{beautiful}
{beautiful}
另一个例子
{time} {home}
{time} {home}
<跨度>&NBSP;&NBSP;&NBSP;&NBSP; {time}
{home}
{time} {home}
我希望你能帮助我。
亲切的问候,
Annemiek
推荐答案
这样做你想要的吗?
Does this do what you want?
Sub InsertLine()
Dim r As Range
Dim s As String
Dim p1 As Long
Dim p2 As Long
设r = Selection.Paragraphs(1).Range
s = r.Text
p1 = InStr(s," {")
如果p1 = 0则退出Sub¥
p2 = InStr(p1 + 1,s,"}")
如果p2 = 0则退出Sub¥
Selection.EndKey单位:= wdLine
Selection.InsertParagraphAfter
Selection.InsertAfter Mid(s,p1,p2 - p1 + 1)
End Sub
Sub InsertLine()
Dim r As Range
Dim s As String
Dim p1 As Long
Dim p2 As Long
Set r = Selection.Paragraphs(1).Range
s = r.Text
p1 = InStr(s, "{")
If p1 = 0 Then Exit Sub
p2 = InStr(p1 + 1, s, "}")
If p2 = 0 Then Exit Sub
Selection.EndKey Unit:=wdLine
Selection.InsertParagraphAfter
Selection.InsertAfter Mid(s, p1, p2 - p1 + 1)
End Sub
这篇关于在Word中创建一个宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!