Hi to all,
i need to export image in the picturebox to word document file in c# windows application
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 14, 2014, 9:45 AM
The AddPicture method can only work with files as opposed to byte streams or arrays.
Manojkumar DuraisamyPosted May 14, 2014, 4:39 AM
pls help me
VulpesPosted May 13, 2014, 7:14 PM
using Word = Microsoft.Office.Interop.Word;
// ...
// export image on a button click, say
private void button1_Click(object sender, EventArgs e)
{
// first save picturebox image to a file
// if it was loaded from a file in the first place
// then save it to a different file
string filePath = "myimage.jpg"; // or whatever
pictureBox1.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
// now load it into a new Word document
Word.Application wordApp = new Word.Application();
wordApp.Visible = false;
Word.Document doc = wordApp.Documents.Add();
doc.InlineShapes.AddPicture(filePath);
doc.SaveAs("myimage.doc"); // or whatever
doc.Close();
wordApp.Quit();
}