将三个对齐的图像添加到word文档页脚

时间:2010-11-05 15:04:46

标签: c# .net-3.5 word-automation

我正在使用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");
            }

这是它正在制作的内容(我添加了注释) Results

这就是我想要的 Desired Response

我需要做什么?

1 个答案:

答案 0 :(得分:0)

我设法修复了这个问题,任何人都遇到了这个问题。我按照这里的说明进行操作:http://support.microsoft.com/kb/316384创建一行,六列表。

如果其他人试图这样做,请不要忘记单词自动化本质上是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);
相关问题