如何通过vb将光标移动到office word中想要的位置? [英] How can I move the cursor to a postion where I want in office word by vb?
本文介绍了如何通过vb将光标移动到office word中想要的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
12345qwesdfasdf22232 &021930
12345qwesdfasdf22232 & 021930
和上面的字符串一样,我想通过搜索字符串中的字符将光标移动到字符&
之后的位置.我用visual basic控制word的时候怎么实现?
Like the string above, I want to move the cursor to the position after the character &
by searching the character in the string. How can I achieve it when I using visual basic to control the word?
Option Explicit
Dim WordApp As Word.Application
Private Sub Command2_Click()
Set WordApp = New Word.Application
WordApp.Documents.Open CommonDialog1.FileName
WordApp.Visible = True
WordApp.DisplayAlerts = False
...
End Sub
推荐答案
如果你使用 Selection.TypeText
输出,你可以使用
If you are outputting using Selection.TypeText
, you can use
Selection.MoveStartUntil "&", wdBackward
Selection.MoveLeft 1
这将使您向后移动,直到第一次出现与号.
which will move you backwards until the first occurrence of the ampersand.
你也可以像 Cindy Meister 提到的那样,做一个 Selection.Find
类似于...
You can also do as Cindy Meister mentioned, do a Selection.Find
similar to...
With Selection.Find
.MatchWildCards = false
.Text = "&"
.Execute
End With
这篇关于如何通过vb将光标移动到office word中想要的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文