作者:乔山办公网日期:
返回目录:word文档
在for语句前加上
Application.ScreenUpdating = true
用完之后的地方加上
Application.ScreenUpdating = False
试一试
1、打开word文档,这个文档有4页。
2、想将光百标迅速移度动到第3页,可以点击开始,替换。
3、弹知出对话框,道点击定位。
4、弹出对话框,点击定位目标内容“页”,专右边输入页号栏输入页码“3”,点击定位。
5、光标就会迅速移动到第3页第第一行位置。
6、要想属定位行,就在左边选择行,在右边输入行号,定位。
7、光标就会迅速移动到指定的行号开头。
Private Sub CommandButton1_Click()
Dim p, r, s, t
s= "石膏板造型顶"
With Selection.Find
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
t = .Execute(FindText:=s)
End With
p= Selection.Information(wdActiveEndPageNumber)
r= Selection.Information(wdFirstCharacterLineNumber)
If t Then
MsgBox "成功,已e5a48de588b67a686964616f335找到“" & s & "”" & vbCrLf & _
"页码:"& p & vbCrLf & "行数:" & r, vbOKOnly, _
"成功"
Else
MsgBox "很遗憾,没有找到“" & s & "”", vbOKOnly, _
"遗憾"
End If
End Sub
写代码很辛苦,好心的楼主请 救济 点儿 悬赏分
移动光标至文档开始
Selection.HomeKey unit:=wdStory
下面的供参考:
Sub MoveToCurrentLineStart()
'移动光标至当前行首
Selection.HomeKey unit:=wdLine
End Sub
Sub MoveToCurrentLineEnd()
'移动光标至当前行尾
Selection.EndKey unit:=wdLine
End Sub
Sub SelectToCurrentLineStart()
'选择从光标至当前行首的内容7a686964616fe59b9ee7ad94366
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