i want to open microsoft word 2007 or 2010
using microsoft visual studio 2010 c#
and add image and text .
i would be greatfull for your help.
C# word
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K pointsPosted Jun 17, 2013, 3:33 AM EDT
Follow the code below: (You need to add reference to "Microsoft.Office.Interop.Word" and "System.Reflection".
------------------------------------
Missing mv = Missing.Value;
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
Document myDoc = WordApp.Documents.Add(mv, mv, mv, mv);
Paragraph paragraph = myDoc.Paragraphs.Add(mv);
myDoc.Content.InsertParagraph();
object start = 0;
object end = 0;
Microsoft.Office.Interop.Word.Range rng = myDoc.Range(ref start,ref end);
rng.Text = "Sample Text";
myDoc.InlineShapes.AddPicture("d:\\network.png", mv, mv, mv);
myDoc.SaveAs("D:\\testDoc.docx", mv, mv, mv, mv, mv, mv, mv, mv, mv, mv, mv, mv, mv, mv, mv);
myDoc = null;
WordApp.Quit(mv, mv, mv);
-------------------------------------------------
Happy Coding :)
Please don't forget to mark this answer if it helps:)
Thanks.