word vba 控制光标常用代码
轉自:https://blog.csdn.net/ssson/article/details/88771194?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-7.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-7.control
Selection.MoveDown Unit:=wdLine, Count:=1'光標下移一行
 ’選中光標所在行
 With Selection
 ? ? ? ? .HomeKey Unit:=wdLine, Extend:=wdExtend
 ? ? ? ? .MoveEnd Unit:=wdLine, Count:=1
 End With
?
移動光標至文檔開始
 Selection.HomeKey unit:=wdStory
 下面的供參考:
 Sub MoveToCurrentLineStart()
 '移動光標至當前行首
 Selection.HomeKey unit:=wdLine
 End Sub
 Sub MoveToCurrentLineEnd()
 '移動光標至當前行尾
 Selection.EndKey unit:=wdLine
 End Sub
 Sub SelectToCurrentLineStart()
 '選擇從光標至當前行首的內容
 Selection.HomeKey unit:=wdLine, Extend:=wdExtend
 End Sub
 Sub SelectToCurrentLineEnd()
 '選擇從光標至當前行尾的內容
 Selection.EndKey unit:=wdLine, Extend:=wdExtend
 End Sub
 Sub SelectCurrentLine()
 '選擇當前行
 Selection.HomeKey unit:=wdLine
 Selection.EndKey unit:=wdLine, Extend:=wdExtend
 End Sub
 Sub MoveToDocStart()
 '移動光標至文檔開始
 Selection.HomeKey unit:=wdStory
 End Sub
 Sub MoveToDocEnd()
 '移動光標至文檔結尾
 Selection.EndKey unit:=wdStory
 End Sub
 Sub SelectToDocStart()
 '選擇從光標至文檔開始的內容
 Selection.HomeKey unit:=wdStory, Extend:=wdExtend
 End Sub
 Sub SelectToDocEnd()
 '選擇從光標至文檔結尾的內容
 Selection.EndKey unit:=wdStory, Extend:=wdExtend
 End Sub
 Sub SelectDocAll()
 '選擇文檔全部內容(從WholeStory可猜出Story應是當前文檔的意思)
 Selection.WholeStory
 End Sub
 Sub MoveToCurrentParagraphStart()
 '移動光標至當前段落的開始
 Selection.MoveUp unit:=wdParagraph
 End Sub
 Sub MoveToCurrentParagraphEnd()
 '移動光標至當前段落的結尾
 Selection.MoveDown unit:=wdParagraph
 End Sub
 Sub SelectToCurrentParagraphStart()
 '選擇從光標至當前段落開始的內容
 Selection.MoveUp unit:=wdParagraph, Extend:=wdExtend
 End Sub
 Sub SelectToCurrentParagraphEnd()
 '選擇從光標至當前段落結尾的內容
 Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
 End Sub
 Sub SelectCurrentParagraph()
 '選擇光標所在段落的內容
 Selection.MoveUp unit:=wdParagraph
 Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
 End Sub
 Sub DisplaySelectionStartAndEnd()
 '顯示選擇區的開始與結束的位置,注意:文檔第1個字符的位置是0
 MsgBox ("第" & Selection.Start & "個字符至第" & Selection.End & "個字符")
 End Sub
 Sub DeleteCurrentLine()
 '刪除當前行
 Selection.HomeKey unit:=wdLine
 Selection.EndKey unit:=wdLine, Extend:=wdExtend
 Selection.Delete
 End Sub
 Sub DeleteCurrentParagraph()
 '刪除當前段落
 Selection.MoveUp unit:=wdParagraph
 Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
 Selection.Delete
 End Sub
?
總結
以上是生活随笔為你收集整理的word vba 控制光标常用代码的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: rbf神经网络和bp神经网络,rbf神经
- 下一篇: 简易PROTUES的定时器仿真
