将三个对齐的图像添加到 Word 文档页脚
我正在使用 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");
}
这是它生成的代码(我添加了注释)
这是我想要的
我需要做什么?
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)
Here is what I want
What do I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法解决了这个问题,以防有人遇到这个问题。我按照此处的说明进行操作:http://support.microsoft.com/kb/316384 创建单行、六列的表格。
如果其他人尝试这样做,请不要忘记文字自动化本质上是 Visual Basic,因此在寻址表格单元格时,索引从 1 开始,而不是 0。
添加文本的工作方式与示例中相同:
添加图像的工作方式与以前一样以前,除了这次范围是您的单元格:
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:
and adding images works like it was previously, except this time the range is your cell: