1、在 WORD 中如何用 VBA 宏语言选定一行、一段,删除一行、一段,移动光标至行首、行尾、段首、段尾等。请看以下内容。Sub MoveToCurrentLineStart()移动光标至当前行首Selection.HomeKey unit:=wdLineEnd SubSub MoveToCurrentLineEnd()移动光标至当前行尾Selection.EndKey unit:=wdLineEnd SubSub SelectToCurrentLineStart()选择从光标至当前行首的内容Selection.HomeKey unit:=wdLine, Extend:=wdExtendEnd
2、SubSub SelectToCurrentLineEnd()选择从光标至当前行尾的内容Selection.EndKey unit:=wdLine, Extend:=wdExtendEnd SubSub SelectCurrentLine()选择当前行Selection.HomeKey unit:=wdLineSelection.EndKey unit:=wdLine, Extend:=wdExtendEnd SubSub MoveToDocStart()移动光标至文档开始Selection.HomeKey unit:=wdStoryEnd SubSub MoveToDocEnd()移动光标至
3、文档结尾Selection.EndKey unit:=wdStoryEnd SubSub SelectToDocStart()选择从光标至文档开始的内容Selection.HomeKey unit:=wdStory, Extend:=wdExtendEnd SubSub SelectToDocEnd()选择从光标至文档结尾的内容Selection.EndKey unit:=wdStory, Extend:=wdExtendEnd SubSub SelectDocAll()选择文档全部内容(从 WholeStory 可猜出 Story 应是当前文档的意思)Selection.WholeStory
4、End SubSub MoveToCurrentParagraphStart()移动光标至当前段落的开始Selection.MoveUp unit:=wdParagraphEnd SubSub MoveToCurrentParagraphEnd()移动光标至当前段落的结尾Selection.MoveDown unit:=wdParagraphEnd SubSub SelectToCurrentParagraphStart()选择从光标至当前段落开始的内容Selection.MoveUp unit:=wdParagraph, Extend:=wdExtendEnd SubSub SelectTo
5、CurrentParagraphEnd()选择从光标至当前段落结尾的内容Selection.MoveDown unit:=wdParagraph, Extend:=wdExtendEnd SubSub SelectCurrentParagraph()选择光标所在段落的内容Selection.MoveUp unit:=wdParagraphSelection.MoveDown unit:=wdParagraph, Extend:=wdExtendEnd SubSub DisplaySelectionStartAndEnd()显示选择区的开始与结束的位置,注意:文档第 1 个字符的位置是 0Msg
6、Box (“第“ & Selection.Start & “个字符至第“ & Selection.End & “个字符“)End SubSub DeleteCurrentLine()删除当前行Selection.HomeKey unit:=wdLineSelection.EndKey unit:=wdLine, Extend:=wdExtendSelection.DeleteEnd SubSub DeleteCurrentParagraph()删除当前段落Selection.MoveUp unit:=wdParagraphSelection.MoveDown unit:=wdParagraph, Extend:=wdExtendSelection.DeleteEnd Sub