Vba 查找文本,插入分页符并重复
如何查找短语,转到短语所在行的开头,插入分页符,然后再次执行宏Vba 查找文本,插入分页符并重复,vba,ms-word,Vba,Ms Word,如何查找短语,转到短语所在行的开头,插入分页符,然后再次执行宏 我尝试了以下操作,但在后续执行时,它不会转到代理名称的以下值 Sub mFI() ' ' mFI Macro ' ' Selection.MoveRight Unit:=wdCharacter, Count:=1 With Selection .Find .ClearFormatting .Forward = True .MatchWholeWo
我尝试了以下操作,但在后续执行时,它不会转到代理名称的以下值
Sub mFI()
' ' mFI Macro ' '
Selection.MoveRight Unit:=wdCharacter, Count:=1
With Selection
.Find
.ClearFormatting
.Forward = True
.MatchWholeWord = True
.MatchCase = False
.Execute FindText:="Agent Name"
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.InsertBreak Type:=wdPageBreak, Count:=1
End Sub
假设您提供的代码是正确的,这将对您有所帮助
Sub mFI()
' ' mFI Macro ' '
Selection.MoveRight Unit:=wdCharacter, Count:=1
With Selection
.Find
.ClearFormatting
.Forward = True
.MatchWholeWord = True
.MatchCase = False
.Execute FindText:="Agent Name"
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.InsertBreak Type:=wdPageBreak, Count:=1
With Selection
.Find
.ClearFormatting
.Forward = True
.MatchWholeWord = True
.MatchCase = False
.Execute FindText:="Agent Name"
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
End Sub
如果要将分页符插入到所有代理名称中,可以尝试
Sub Demo()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Agent Name"
.Replacement.Text = "^m^&"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
为了了解如何实现这些目标,您已经做了哪些研究?我已经尝试了以下内容,但在后续执行时不会涉及代理名称的以下值。子mFI“”mFI宏“”Selection.MoveRight单位:=wdCharacter,计数:=1,带Selection.Find.ClearFormatting.Forward=True.MatchWholeWord=True.MatchCase=False.Execute FindText:=代理名称,带Selection.MoveRight单位:=wdCharacter,计数:=1个选择。向下移动单位:=wdLine,计数:=1个选择。插入中断类型:=wdPageBreak,计数:=1个结束细分这解决了您的问题吗?如果没有,请告诉我们更多