C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Insert image in header/footer of word document


Posted Date: 11 Oct 2008      Total Responses: 1

Posted By: jeya sakthi vel murugan       Member Level: Bronze     Points: 1



Hi!
I need the coding for Insert image in header/footer of word document using C#, Windows Application




Responses

Author: Bhushan Poojary    13 Oct 2008Member Level: SilverRating:     Points: 6
using Microsoft.Office.Interop.Word...Source(http://nishantrana.wordpress.com/2008/07/17/opening-and-inserting-a-picture-in-word-document-programmatically-using-c/)


Put the following code in the button click event handler

// For optional parameters create a missing object
object missing = System.Reflection.Missing.Value;
// Create an object for filename, which is the file to be opened
object fileName=@”C:\MySecond.doc”;
// Create an object of application class
ApplicationClass WordApp = new ApplicationClass();
// open the document specified in the fileName variable
Document adoc = WordApp.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
// We can insert the picture using Range objects AddPicture method
// To insert a picture at a particular location in the word document
// insert a table over there and then refer that location through range object
Range rngPic = adoc.Tables[1].Range;
// we can even select a particular cell in the table
//Range rngPic = rng.Tables[1].Cell(2, 3).Range;
rngPic.InlineShapes.AddPicture(@”C:\anne_hathaway.jpg”, ref missing, ref missing, ref missing);
WordApp.Visible = true;

[\CODE]



Post Reply
You must Sign In to post a response.
Next : How to add user control in GAC ?
Previous : Convert PHP to .Net
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

audio conferencing services

Contact Us    Privacy Policy    Terms Of Use