将三个对齐图像添加到Word文档页脚
-
29-09-2019 - |
题
我正在使用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");
}
这是它产生的(我添加了注释)
这是我想要的
我需要做什么?
解决方案
我设法解决了任何人遇到这个问题的问题。我在这里遵循说明: http://support.microsoft.com/kb/316384 要创建一个行,请使用六列表。
如果其他人试图做到这一点,请不要忘记单词自动化本质上是视觉基本的,因此在解决表单元格时,索引从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);
不隶属于 StackOverflow