0

我的 Access 数据库包含一个 OLE 对象“Microsoft Word 97 - 2003”。这是我尝试将 OLE 对象写入 .doc 文件,并将其显示在 WebBrowser 控件中:

Private Sub LoadBlob(objDataTable As DataTable)

    Dim WordBlob() As Byte = Nothing
    Dim TrimWordBlob() As Byte = Nothing
    Dim FileName As String
    Dim objStream As Stream

    Try
        If objDataTable(0).Item("DescriptionWord") IsNot DBNull.Value Then
            WordBlob = CType(objDataTable(0).Item("DescriptionWord"), Byte())
        End If
        FileName = libGlobal.App_Path & "\temp.doc"

        TrimWordBlob = New Byte(WordBlob.Length - 86) {}
        Buffer.BlockCopy(WordBlob, 85, TrimWordBlob, 0, TrimWordBlob.Length)
        System.IO.File.WriteAllBytes(FileName, TrimWordBlob)

        objStream = New MemoryStream(TrimWordBlob)
        objStream.Position = 0
        Me.wbrDocument.DocumentStream = objStream

    Catch ex As Exception
        libError.ShowErrorMessage(ex)
    End Try
End Sub

Temp.doc 不是有效的 Word 文档,并且 WebBrowser 控件不显示任何内容。你能告诉我我的方式的错误吗?

4

1 回答 1

0

我不认为它适用于 Word 文件,但我用于 HTA 类型浏览的一种技术是为 .hta 文件构建文本,保存文件,然后使用 Process.Start()。这是一个可以打开文件的 .hta 文件(如果它有用的话)。通常,该 URL 只是 HTA 支持的文档类型的典型 URL。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <!--intro: http://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx-->
 <!--ref:   http://msdn.microsoft.com/en-us/library/ms536473(v=VS.85).aspx-->
 <html>
 <head>
 <title>Your Page Title</title>
   <hta:application id="oMyApp" 
     applicationname="EnvView" 
     border="thin"
     caption="yes"
     showintaskbar="yes"
     minimizeButton="yes"
     singleinstance="yes"
     sysmenu="yes"
     windowstate="maximize"
     navigable="yes" >
     <!--use title="none" for full desktop - use Alt-F4 to close-->
 <meta http-equiv="REFRESH" content="0;url=file://filepath"></HEAD>
 <BODY>
 if load fails use Alt-F4 to close
 </BODY>
 </HTML>
于 2013-07-18T19:34:23.747 回答