C# 向word文档页脚添加三个对齐的图像

C# 向word文档页脚添加三个对齐的图像,c#,.net-3.5,word-automation,C#,.net 3.5,Word Automation,我正在使用Word Automation从我的应用程序创建一个文档,我需要在文档的页脚添加三个签名。这很容易,但是,让它们看起来像我想要的那样是行不通的 以下是我使用的代码: //add initials to footer if (oWordDoc.Sections.Count > 0) { Range r = oWordDoc.Sections[1].Footers[WdHeaderFooterIndex.

我正在使用Word Automation从我的应用程序创建一个文档,我需要在文档的页脚添加三个签名。这很容易,但是,让它们看起来像我想要的那样是行不通的

以下是我使用的代码:

            //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");
            }
下面是它产生的结果(我添加了注释)

这是我想要的


我需要做什么?

我设法解决了这个问题,以防有人遇到这个问题。我按照这里的说明:创建一个单行、六列的表

如果其他人正在尝试这样做,请不要忘记word automation本质上是Visual Basic,因此在寻址表单元格时,索引从1开始,而不是从0开始

添加文本的工作原理如示例所示:

oTable.Cell(1, 2).Range.Text = "Plaintiff's Initials";
添加图像的工作原理与以前一样,但这次的范围是您的单元格:

oTable.Cell(1, 1).Range.InlineShapes.AddPicture(plaintiffInitialFile, ref oMissing, ref oTrue, ref oMissing);