在vb里,如何进行在word的某一位置插入字符的操作

解决方案 »

  1.   

    现将我的一段代码给你参考!!不过先在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中的帮助中有
    然后插入文字。
      

  2.   

    用word的查找方法找到"你好",然后按Tab键把光标移到下一个单元格
      

  3.   

    你的位置如果是固定的话,完全可以使用“书签”BookMark
      

  4.   

    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
        
    End Sub
      

  5.   

    比如,我已经把"你好"后面的单元格定义为书签"RepStr",我要将字符"hello world"放到"你好"后的单元格内,如何写代码,谢谢
      

  6.   

    你说的完全可以用表格对象操作,定位单元格还不是超简单的问题。
    学会看word的vba帮助才是最好的办法。
      

  7.   

    ActiveDocument.Books("RepStr").range.text="Hello World"
      

  8.   

    谢谢,我定义一个窗体域RepStr,用Document对象.FormFields("RepStr").Result = "Hello World"
    已解决