PDA

View Full Version : سوال: انتقال عکس به فایل ورد



09178525592
چهارشنبه 22 خرداد 1392, 18:56 عصر
سلام دوستان .

چجوری میتونیم یه عکس که داخل pcturebox هست رو به یک مکان مشخص داخل فایل ورد انتقال بدیم؟؟؟

09178525592
چهارشنبه 22 خرداد 1392, 20:09 عصر
کسی بلد نیست؟؟؟؟؟؟؟؟؟؟

tooraj_azizi_1035
چهارشنبه 22 خرداد 1392, 20:29 عصر
private void button1_Click(object sender, EventArgs e)
{
// first we are creating application of word.
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
// now creating new document.
WordApp.Documents.Add();
// see word file behind your program
WordApp.Visible = true;
// get the reference of active document
Microsoft.Office.Interop.Word.Document doc = WordApp.ActiveDocument;
// set openfiledialog to select multiple image files
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF";
ofd.Title = "Select Image To Insert....";
ofd.Multiselect = true;
// if user select OK, then process for adding images
if (ofd.ShowDialog() == DialogResult.OK)
{
// iterating process for adding all images which is selected by filedialog
foreach (string filename in ofd.FileNames)
{
// now add the picture in active document reference
doc.InlineShapes.AddPicture(filename, Type.Missing, Type.Missing, Type.Missing);
}
}
// file is saved.
doc.SaveAs("c:\\hello.doc", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// application is now quit.
WordApp.Quit(Type.Missing, Type.Missing, Type.Missing);
}



http://www.c-sharpcorner.com/UploadFile/hrojasara/insert-multiple-image-in-word-file-using-C-Sharp/Images/2.gifhttp://www.c-sharpcorner.com/UploadFile/hrojasara/insert-multiple-image-in-word-file-using-C-Sharp/Images/2.gif