在WORD中用VBA实现光标移动与内容选择

您所在的位置:网站首页 word怎么移动段落到另一个段落 在WORD中用VBA实现光标移动与内容选择

在WORD中用VBA实现光标移动与内容选择

2024-05-11 20:04| 来源: 网络整理| 查看: 265

Sub 宏2()

'

' 宏2 宏

'

'

    Selection.MoveUp unit:=wdParagraph

    Selection.InsertBefore Text:="new text"

    Selection.InsertAfter Text:="The end"

    Selection.MoveLeft unit:=wdCharacter, Count:=1

End Sub

 

Sub 宏4()

'

' 宏4 宏

'

'

Set myRange = ActiveDocument.Content

  myRange.Find.Execute FindText:=",", ReplaceWith:=",^p^t", Replace:=wdReplaceAll

 

End Sub

 

宏F12、在?。后加入换行

 

宏F11、将    ,:     :,  :。    。:   ?:  :?  都替换成:“

 

宏F10、替换正确的关键词,领域时——领域石,小孩——小黑

 

宏F9、将数字都替换为中文

 

宏F1、到行首,加入“

 

宏F2、到行尾,加入”

 

宏F3、到行尾

 

宏F4、到行尾,Selection.Delete Unit:=wdCharacter, Count:=2       删除2个换行

 

宏F5、插入“

 

宏F6、插入”

 

 

开始

a=selection.start

 

结尾

b=selection.end

 

Selection.InsertBefore Text:="new text"

Selection.InsertAfter Text:="The end."

Sub MoveToCurrentParagraphStart()

    '移动光标至当前段落的开始

    Selection.MoveUp unit:=wdParagraph

End Sub

Sub MoveToCurrentParagraphEnd()

    '移动光标至当前段落的结尾

    Selection.MoveDown unit:=wdParagraph

End Sub

 

Selection.MoveUp unit:=wdParagraph

Selection.InsertBefore Text:="new text "

Selection.MoveDown Unit:=wdParagraph

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.InsertAfter Text:="The end."

 

    Selection.Delete Unit:=wdCharacter, Count:=1

    Selection.TypeBackspace

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3