JasonSummers
Programmer
Hello,
I am trying to programatically add an Image to a word document. I have managed to do that with the COde below. However, I need to insert it into a table that is in the document header. I can insert it into a table in the main body, but cant figure out how to set the range to a cell in a table in the header. Any help will be appreciated.
Thank you.
private void button1_Click(object sender, EventArgs e)
{
//OBJECT OF MISSING "NULL VALUE"
Object oMissing = System.Reflection.Missing.Value;
//OBJECTS OF FALSE AND TRUE
Object oTrue = true;
Object oFalse = false;
//CREATING OBJECTS OF WORD AND DOCUMENT
Word.Application oWord = new Word.Application();
Word.Document oWordDoc = new Word.Document();
//MAKING THE APPLICATION VISIBLE
oWord.Visible = true;
object fileName = @"C:\asheets\Form B03.02A2.DOC";
oWordDoc = oWord.Documents.Open(ref fileName,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);
//SETTING FOCUES ON THE PAGE HEADER
oWord.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;
Word.Shape logoCustom = null;
//THE PATH OF THE LOGO FILE TO BE EMBEDDED IN THE HEADER
String logoPath = "C:\\Test.jpg";
logoCustom = oWord.Selection.HeaderFooter.Shapes.AddPicture(logoPath,ref oFalse, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
logoCustom.Select(ref oMissing);
logoCustom.Name = "CustomLogo";
logoCustom.Left = (float)Word.WdShapePosition.wdShapeLeft;
}
}
}
I am trying to programatically add an Image to a word document. I have managed to do that with the COde below. However, I need to insert it into a table that is in the document header. I can insert it into a table in the main body, but cant figure out how to set the range to a cell in a table in the header. Any help will be appreciated.
Thank you.
private void button1_Click(object sender, EventArgs e)
{
//OBJECT OF MISSING "NULL VALUE"
Object oMissing = System.Reflection.Missing.Value;
//OBJECTS OF FALSE AND TRUE
Object oTrue = true;
Object oFalse = false;
//CREATING OBJECTS OF WORD AND DOCUMENT
Word.Application oWord = new Word.Application();
Word.Document oWordDoc = new Word.Document();
//MAKING THE APPLICATION VISIBLE
oWord.Visible = true;
object fileName = @"C:\asheets\Form B03.02A2.DOC";
oWordDoc = oWord.Documents.Open(ref fileName,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);
//SETTING FOCUES ON THE PAGE HEADER
oWord.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;
Word.Shape logoCustom = null;
//THE PATH OF THE LOGO FILE TO BE EMBEDDED IN THE HEADER
String logoPath = "C:\\Test.jpg";
logoCustom = oWord.Selection.HeaderFooter.Shapes.AddPicture(logoPath,ref oFalse, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
logoCustom.Select(ref oMissing);
logoCustom.Name = "CustomLogo";
logoCustom.Left = (float)Word.WdShapePosition.wdShapeLeft;
}
}
}