-1
我有一個C#項目與Microsoft Access數據庫。在表格中我有一個帶有OLE對象(Word文件)的列。解決方法是 - 使用C#從數據庫打開附加的Word文件。在互聯網上發現了很多帶有圖像的例子,但沒有使用Word文件的例子。MS Access中提取Word OLE對象
我試過了,但沒有奏效。任何幫助?
string strSQL = "SELECT Attach FROM tbl_example WHERE ID=1";
OleDbCommand cmd = new OleDbCommand(strSQL, con);
var oleBytes = (Byte[])cmd.ExecuteScalar();
const int offset = 85;
MemoryStream ms = new MemoryStream();
ms.Write(oleBytes, offset, oleBytes.Length - offset);
Word.Application newWordApp = new Word.Application();
newWordApp.Visible = true;
Word.Document newWordDoc = newWordApp.Documents.Open(ms);
您當前發佈的代碼是行不通的嗎? – Rahul
對不起...是的最後一個代碼行不起作用。這是不可能採取MemoryStream和Word.Dociment .... –