Processing
 

c# access extract word ole object

18/09/2016 16:57#1

Jörg

Member

Joined at: 9 months ago

Post: 4

Thank: 0

Thanked: 0

I have an C# Project with an Microsoft Access Database. Inside the Table i have a Column with attached OLE Objects (Word Files). Solution is - open this attached Word Files from Database with C#. Found in the Internet so many Examples with Images, but no Example with an Word File.

This i tryed. But not works. Anyone so friendly have an Solution? Thanks!

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); 
19/09/2016 18:45Top#2

Jörg

Member

Joined at: 9 months ago

Post: 4

Thank: 0

Thanked: 0

I am re-design the code. Now with this example - the OLE word document will be read and will saved. When i will double clicked to open the saved word document on folder test - first word application open and bring me the message, the word file is corrupt. Then i press OK button and the document will be open... with all text and pictures are saved as OLE object in the database. So it will work now 99% :D ... this code works, no stop at debugging. but the new saved word file (from access ole db) is a little bit corrupt...

        string strSQL = "SELECT Anhang FROM tbl_inhalte WHERE ID=1";         OleDbCommand cmd = new OleDbCommand(strSQL, con);         var oleBytes = (Byte[])cmd.ExecuteScalar();          File.WriteAllBytes(@"c:\test\worddatei.docx", oleBytes.Skip(0).ToArray()); 
Similar articles

VBA regex matching over two lines

4 months ago - Reply: 1 - Views: 44

Table output to Word-2011 from Rstudio using knit

4 months ago - Reply: 0 - Views: 28

Write a Collection of paragraphs into a new document

4 months ago - Reply: 1 - Views: 70

how to write paragraphs without show to document

4 months ago - Reply: 1 - Views: 66

numericals in word macro

4 months ago - Reply: 1 - Views: 45

Can not find proofing tools

4 months ago - Reply: 0 - Views: 1

Possible values for <w:outlineLvl> in Word OOXML

4 months ago - Reply: 1 - Views: 7

C# restrict editing partial word paragraph

5 months ago - Reply: 2 - Views: 142

Macro translation Please (possible virus)

4 months ago - Reply: 1 - Views: 34

Doc/Docx Fastest Reading Method for Searching

4 months ago - Reply: 0 - Views: 1

Save embedded file / content from word

4 months ago - Reply: 0 - Views: 5

Counting words in Word document, including footnores

4 months ago - Reply: 1 - Views: 22

c# access extract word ole object

4 months ago - Reply: 1 - Views: 19

Using word wildcards to find unaccepted changes

4 months ago - Reply: 1 - Views: 45

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re