Question

I am using Word Automation to create a document from my application, and I need to add three signatures to the footer of a document. That is easy, however, getting them to appear as I would like isn't working.

Here's the code I'm using:

            //add initials to footer
            if (oWordDoc.Sections.Count > 0) {
                Range r = oWordDoc.Sections[1].Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                Object colapseDir = WdCollapseDirection.wdCollapseStart;
                r.Collapse(ref colapseDir);

                oWord.ActiveWindow.View.Type = WdViewType.wdPrintView;
                oWord.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageFooter;
                oWord.Selection.TypeParagraph();

                oWord.Selection.Paragraphs.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
                oWord.ActiveWindow.Selection.Font.Name = "Arial";
                oWord.ActiveWindow.Selection.Font.Size = 8;


                if (!String.IsNullOrEmpty(plaintiffInitialFile)) {
                    r.InlineShapes.AddPicture(plaintiffInitialFile, ref oMissing, ref oTrue, ref oMissing);
                }

                oWord.ActiveWindow.Selection.TypeText("Plaintiff's Initals");
                oWord.ActiveWindow.Selection.TypeText("\t");


                if (!String.IsNullOrEmpty(plaintiffAttInitialFile)) {
                    r.InlineShapes.AddPicture(plaintiffAttInitialFile, ref oMissing, ref oTrue, ref oMissing);
                }

                oWord.ActiveWindow.Selection.TypeText("Plaintiff's Attorney's Initals");
                oWord.ActiveWindow.Selection.TypeText("\t");


                if (!String.IsNullOrEmpty(ekfgInitialFile)) {
                    r.InlineShapes.AddPicture(ekfgInitialFile, ref oMissing, ref oTrue, ref oMissing);
                }

                oWord.ActiveWindow.Selection.TypeText("EKFG's Initals");
            }

Here is what it is producing (I've added annotations) Results

Here is what I want Desired Response

What do I need to do?

Was it helpful?

Solution

I managed to fix the issue incase anyone runs into this problem. I followed the instructions here: http://support.microsoft.com/kb/316384 to create a single row, six column table.

If someone else is trying to do this, do not forget that word automation is essentially Visual Basic, so when addressing the table cells, indexes start at 1, not 0.

Adding text works like in the example:

oTable.Cell(1, 2).Range.Text = "Plaintiff's Initials";

and adding images works like it was previously, except this time the range is your cell:

oTable.Cell(1, 1).Range.InlineShapes.AddPicture(plaintiffInitialFile, ref oMissing, ref oTrue, ref oMissing);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top