代码之家  ›  专栏  ›  技术社区  ›  Malfist

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

  •  0
  • Malfist  · 技术社区  · 14 年前

    我使用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 回复  |  直到 14 年前
        1
  •  0
  •   Malfist    14 年前

    我设法解决了这个问题,以防有人碰到这个问题。我遵循了这里的说明: http://support.microsoft.com/kb/316384 创建一个单行六列表。

    如果其他人试图这样做,请不要忘记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);
    
    推荐文章