I want to read header from word document
I want to read the word document header and get the specific string in a label, Kindly help me
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Bharath PeggemRank #3,303 · 435 reputationPosted Nov 4, 2015, 6:44 PM EST
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = false; //to avoid displaying the Word Application
object strDocName = @"d:\test.doc";
object objBool = false;
object objNull = System.Reflection.Missing.Value;
Document oMyDoc = oWord.Documents.Open(ref strDocName, ref objBool, ref objBool, ref objBool, ref objNull,
ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull);
object objReference = System.Reflection.Missing.Value;
object objFoot = "this is footer";
object objStart = 0;
object objEnd = oMyDoc.Words.Count;
if (oMyDoc.Sections.Count > 0)
{
oMyDoc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "My Header";
oMyDoc.Sections[1].Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "My Footer";
}
Bharath PeggemRank #3,303 · 435 reputationPosted Oct 31, 2015, 3:56 AM EDT
praveen kumar185 reputationPosted Nov 1, 2015, 5:35 PM EST
Bharath PeggemRank #3,303 · 435 reputationPosted Nov 1, 2015, 6:48 PM EST
praveen kumar185 reputationPosted Nov 1, 2015, 8:08 PM EST
Bharath PeggemRank #3,303 · 435 reputationPosted Nov 1, 2015, 8:45 PM EST
praveen kumar185 reputationPosted Nov 1, 2015, 11:35 PM EST
praveen kumar185 reputationPosted Nov 4, 2015, 6:54 PM EST
praveen kumar185 reputationPosted Nov 4, 2015, 6:58 PM EST
Bharath PeggemRank #3,303 · 435 reputationPosted Nov 4, 2015, 7:34 PM EST
praveen kumar185 reputationPosted Nov 11, 2015, 5:24 PM EST