chetan Allipur

chetan Allipur

  • NA
  • 541
  • 167.8k

I am replacing the field with text.So format is not correct

Jul 17 2017 2:57 AM
I am replacing the field with text in Headers. I am getting document page is not showing correct format.
 
Here is my code.
 
 
foreach (Microsoft.Office.Interop.Word.Section section in oWordDoc.Sections)
{
oWordDoc.TrackRevisions = false;
Microsoft.Office.Interop.Word.HeadersFooters headers = section.Headers;
foreach (Microsoft.Office.Interop.Word.HeaderFooter header in headers)
{
//Fields fields = header.Range.Fields;
foreach (Field field in header.Range.Fields)
{
if (field.Type == WdFieldType.wdFieldDocProperty)
{
field.Select();
if (field.Code.Text.Contains("CompanyName"))
{
ap.Selection.TypeText(Manufacturer.Text);
}
else if (field.Code.Text.Contains("ProductName"))
{
ap.Selection.TypeText(Product.Text);
}
}
}
}
}
 
 
Please anyone Help me