现将我的一段代码给你参考!!不过先在vb中引入word Private Sub Command3_Click() Dim oWordApp As Word.Application Dim DQDoc As Word.Document Set oWordApp = New Word.Application oWordApp.Visible = False '不显示word Set DQDoc = oWordApp.Documents.Open("C:\Documents and Settings\zhoujj1\桌面\03.doc") '打开文档 Dim myrange As Range Dim myrange1 As Range Set myrange = ActiveDocument.Content myrange.Find.Execute findtext:="Θ", Forward:=True '根据一个字符选取一个插入点 如不选去,则插入点在文件头部 然后移动光标,可以一行或一个字符。。在word vba中的帮助中有 然后插入文字。
用word的查找方法找到"你好",然后按Tab键把光标移到下一个单元格
你的位置如果是固定的话,完全可以使用“书签”BookMark
Sub Macro4() Dim ss As String Dim aa As Book
ss = "123456780000" Set Book = ActiveDocument.Books.Add("书签1", ActiveDocument.Range(10)) Book.Range.Text = ss ActiveDocument.Range(ActiveDocument.Books(2).Start, ActiveDocument.Books(2).Start + Len(ss)).Font.Color = wdColorRed
Private Sub Command3_Click()
Dim oWordApp As Word.Application
Dim DQDoc As Word.Document Set oWordApp = New Word.Application
oWordApp.Visible = False '不显示word
Set DQDoc = oWordApp.Documents.Open("C:\Documents and Settings\zhoujj1\桌面\03.doc") '打开文档
Dim myrange As Range
Dim myrange1 As Range
Set myrange = ActiveDocument.Content
myrange.Find.Execute findtext:="Θ", Forward:=True '根据一个字符选取一个插入点
如不选去,则插入点在文件头部
然后移动光标,可以一行或一个字符。。在word vba中的帮助中有
然后插入文字。
Dim ss As String
Dim aa As Book
ss = "123456780000"
Set Book = ActiveDocument.Books.Add("书签1", ActiveDocument.Range(10))
Book.Range.Text = ss
ActiveDocument.Range(ActiveDocument.Books(2).Start, ActiveDocument.Books(2).Start + Len(ss)).Font.Color = wdColorRed
End Sub
学会看word的vba帮助才是最好的办法。
已解决