怎样读word文档到richtext中???????????

解决方案 »

  1.   

    wordpad 或 rtf的可以,其他的可能不能直接到richtext中
      

  2.   

    Private Sub CmdImport_Click()
    ''''导入word文档
        On Error GoTo Showerr
        CDlg.Filter = "文档文件(*.doc;*.txt)|*.doc;*.txt|图片文件(*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"
        CDlg.ShowOpen
        If CDlg.FileName = "" Then Exit Sub
        FileName = CDlg.FileName
        If FileLen(FileName) \ 1024 \ 1024 < 1 Then
            Me.Enabled = False
            rtfData.Locked = False
            rtfData.OLEObjects.Clear
            rtfData.OLEObjects.Add , , FileName
            strExtendName = UCase(Right(FileName, 3))
            If strExtendName = "DOC" Or strExtendName = "BMP" Then
               rtfData.OLEObjects(0).DisplayType = rtfDisplayIcon
            End If
            li_flag = 1
            rtfData.Locked = True
            Me.Enabled = True
        Else
            MsgBox "附件文件不得大于1M,请重新选择!", vbOKOnly + vbCritical, Me.Caption
        End If
        Exit Sub
    Showerr:
        Me.Enabled = True
        If Err.Number <> 32775 Then
            MsgBox Err.Description, vbOKOnly + vbCritical, Me.Caption
        End If
    ''''导入word文档内容
        Dim App As Word.Application
        Dim Doc As Word.Document
        Set App = New Word.Application
        Set Doc = App.Documents.Open(FileName)
        Doc.SaveAs Left(FileName, Len(FileName) - 3) & "rtf", 6
        rtfData.LoadFile Left(FileName, Len(FileName) - 3) & "rtf"
        Kill Left(FileName, Len(FileName) - 3) & "rtf"
    End Sub