【问题标题】:VSTO Word 2010 Add-in VB.netVSTO Word 2010 外接程序 VB.net
【发布时间】:2014-06-30 09:24:49
【问题描述】:

目前我已经编写了一个插件,它将下拉菜单中的值设置为文档的标题。它可以放在页眉或页脚中,但是我的代码目前都覆盖了该部分中的所有内容。当发送文档或用户尝试使用模板时,这会导致问题。知道如何使代码与当前上方或下方的代码“合并”吗?

代码片段:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    On Error GoTo err

    Dim classification As String
    Dim dc As Microsoft.Office.Interop.Word.Document

    dc = Globals.ThisAddIn.Application.ActiveDocument
    classification = "Classification: " & ComboBox1.Text

    With dc

        .ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader
        .ActiveWindow.Selection.HeaderFooter.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
        .ActiveWindow.Selection.HeaderFooter.Range.Text = classification
        .ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekMainDocument

    End With

    Me.Hide()

    Exit Sub

只是让您知道您可以看到的额外代码是搜索当前不存在的分类,如果存在则不显示表单(设置如下)。

谢谢,

查尔斯

【问题讨论】:

    标签: vb.net vsto


    【解决方案1】:

    我已经为任何有兴趣的人解决了这个问题,你可以换线....

    ActiveWindow.Selection.HeaderFooter.Range.Text = 分类

    与以下一个:

    .ActiveWindow.Selection.HeaderFooter.Range.Text = .ActiveWindow.Selection.HeaderFooter.Range.Text + 分类

    但请注意,它会破坏当前存在的任何格式...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      相关资源
      最近更新 更多