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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 13, 2014, 3:14 PM EDT
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();
}
Manojkumar Duraisamy29 reputationPosted May 14, 2014, 12:39 AM EDT
pls help me
VulpesRank #55 · 29.2K reputationPosted May 14, 2014, 5:45 AM EDT
The AddPicture method can only work with files as opposed to byte streams or arrays.