我的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控件不显示任何内容。 你能告诉我我的方式错误吗?
答案 0 :(得分: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>