最好不要用SendKey而使用 OLE Automate 调用Word对象。

解决方案 »

  1.   

    或者您可以直接调用word.application对象操作
      

  2.   

    Private Sub Command2_Click()
        Dim oword As Word.Application
        Dim aa As Word.Document
        
        Set oword = CreateObject("Word.Application")
        oword.Documents.Open "i:\test.doc"
        
        Set aa = oword.ActiveDocument
        
        aa.Range.Copy
        MsgBox Clipboard.GetText
        aa.Close
        Set aa = Nothing
        Set oword = Nothing
    End Sub
      

  3.   

    用RichTextBox显示Word里的内容,更丰富多彩,具体方法如下:
    Private Sub Openfile(byval strWordDoc as String)
    dim m_strTmpRtfFile as String
    Dim objWord As Object
    Dim objWordDocument As Word.Document
    Const CLASSOBJECT = "Word.Application"
    m_strTmpRtfFile = app.path & "\tmp.rtf"
    If (objWord Is Nothing) Then
       Set objWord = CreateObject(CLASSOBJECT)
    End If
    Set objWordDocument = objWord.Documents.Open(FileName:=strWordDoc)
    objWord.Visible = False
    objWordDocument.SaveAs m_strTmpRtfFile, wdFormatRTF '另存为RTF格式
       
    Set objWordDocument = Nothing
    objWord.Quit SaveChanges:=wdDoNotSaveChanges                          '退出Word
    Set objWord = Nothing
    If Dir(m_strTmpRtfFile) <> "" Then
        RichTextBox1.LoadFile m_strTmpRtfFile, 0
        Kill m_strTmpRtfFile
    End If
    End sub
      

  4.   

    好货到了text 有很多东西会丢失
    到了RichText丢少点