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.
Loading
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.
Sunny SharmaPosted Jun 17, 2013, 7:33 AM
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.