E
Evan Stone
Hello,
I'm dynamically building a Table in Word (via automation in C#), and I need
to be able to set the horizontal alignment of the text (just right or left
for now - I'm not worrying about center), and here's how I'm (trying) to do
it:
//-----------------------------
Word.Cell currentCell =
wordTable.Cell(wordTable.Rows.Count, i);
currentCell.Range.Text = textValueToInsert;
Word.Paragraph currentParagraph =
currentCell.Range.Paragraphs.Item(1);
currentParagraph.Alignment = GetDetailTableFieldAlignment(fieldName);
//-----------------------------
(FYI, GetDetailTableFieldAlignment() is a method that returns
wdAlignParagraphRight or wdAlignParagraphLeft, depending on certain criteria
in a data table that I interrogate. The interrogation process is working
properly and is returning the appropriate values.)
What I'm finding is that if wdAlignParagraphLeft is returned, it seems to
format OK. Howefver, if wdAlignParagraphRight is returned, the text that is
inserted in the second line gets deleted when the alignment is applied in
the fourth line.
Perhaps I'm doing it incorrectly -- I get the feeling I'm missing an
important part to the puzzle, like perhaps I'm using the wrong object (i.e.
Paragraph) or something along those lines. If so, I'd like to know how to
get it to work properly, and if anyone has any suggestions I'd really
appreciate it!
Thanks in advance...
evan stone | software engineer
I'm dynamically building a Table in Word (via automation in C#), and I need
to be able to set the horizontal alignment of the text (just right or left
for now - I'm not worrying about center), and here's how I'm (trying) to do
it:
//-----------------------------
Word.Cell currentCell =
wordTable.Cell(wordTable.Rows.Count, i);
currentCell.Range.Text = textValueToInsert;
Word.Paragraph currentParagraph =
currentCell.Range.Paragraphs.Item(1);
currentParagraph.Alignment = GetDetailTableFieldAlignment(fieldName);
//-----------------------------
(FYI, GetDetailTableFieldAlignment() is a method that returns
wdAlignParagraphRight or wdAlignParagraphLeft, depending on certain criteria
in a data table that I interrogate. The interrogation process is working
properly and is returning the appropriate values.)
What I'm finding is that if wdAlignParagraphLeft is returned, it seems to
format OK. Howefver, if wdAlignParagraphRight is returned, the text that is
inserted in the second line gets deleted when the alignment is applied in
the fourth line.
Perhaps I'm doing it incorrectly -- I get the feeling I'm missing an
important part to the puzzle, like perhaps I'm using the wrong object (i.e.
Paragraph) or something along those lines. If so, I'd like to know how to
get it to work properly, and if anyone has any suggestions I'd really
appreciate it!
Thanks in advance...
evan stone | software engineer