0

I am trying to put pictures from SQL database to MS Word. I'm using the MS.Office.Interop interface. The picture is in binary format.

The only comannd I found was the following:

Public Sub Add_RowWithPictures(XMLFile As String)
   '### Füge Zeile mit definierten Spalten ein'
    Dim wTab As Word.Table = oDoc.Tables.Add(oDoc.Paragraphs(oDoc.Paragraphs.Count).Range, 1, 1)
    Dim rng = wTab.Cell(1, 1).Range
    rng.InsertXML(XMLFile)
End Sub

But for this I need a conversion to XML.

Could anyone please help me? It is the first time i work with binary files.

Thank you very much!

preciousbetine
  • 2,959
  • 3
  • 13
  • 29
Hias
  • 45
  • 6
  • Once you start working with Word objects the offering is pretty much the same in VBA as in an interop language. So record a macro in word that does the task you are trying to implement, look at the methods that are used in the * usually very bad ) VBA code that is generated, then look for the same/similar methods via intetop. – freeflow Nov 28 '19 at 15:42
  • My picture is in binary format. So, unfortunately i can't put this binary-number into word and record it with the macro recorder. It also would help me when i can export this binary-Number in SQL to a .png File. Then i could save it temporary and get it on Folderpath. Then i could paste the picture with rng.Inlineshape(path) – Hias Nov 28 '19 at 15:54
  • What binary format? – freeflow Nov 28 '19 at 16:49
  • Does this answer your question? [How to insert image in a existing word document with c#](https://stackoverflow.com/questions/29400201/how-to-insert-image-in-a-existing-word-document-with-c-sharp) – T.S. Nov 29 '19 at 22:23
  • sorry for the late answer: The format was a binary-array. I didn't know that, i thougt it was a string. So therefore i could export it to Fileserver as a .png picture and put it in word per interop (.Range.InlineShapes.Add(path as string)). Thats the only way to paste pictures per interop-interface. But nevertheless it's works and it's really fast. I didn't expect that! – Hias Dec 04 '19 at 14:21

0 Answers0