'how to split into lines c# word document
Help me to solve this problem - how to insert text into a Word document so that the first line of each sheet has an inscription, for example "continuation of the table". I suppose to do it like this...Find the lines of each of the pages and on each page find the first line and insert. Maybe it can be done differently ... more gracefully) But even with my approach, not all lines are displayed.
try
{
for (int ii = 1; ii < LineCount; ii++)
{
CurrentPageNumber = (Convert.ToInt32(ii.ToString()));
NextPageNumber = (Convert.ToInt32((ii + 1).ToString()));
// Get start position of current page
Start = oWord.Selection.GoTo(ref What, ref Which, ref CurrentPageNumber, ref Miss).Start;
// Get end position of current page
End = oWord.Selection.GoTo(ref What, ref Which, ref NextPageNumber, ref Miss).End;
var rng_page = docDocument.Range(Start, End);
string textLine = rng_page.Text;
Console.WriteLine(textLine);
var line_rng= docDocument.Range(unit);
string textline_line = line_rng.Text;
//Console.WriteLine(textline_line);
}
}
catch (Exception ex)
{
_ = ex.Message;
}
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
