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

发布于 2024-10-01 00:04:31 字数 2019 浏览 1 评论 0原文

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

这是它生成的代码(我添加了注释) 结果

这是我想要的 Desired Response

我需要做什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2024-10-08 00:04:31

我设法解决了这个问题,以防有人遇到这个问题。我按照此处的说明进行操作: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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文