【发布时间】: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
只是让您知道您可以看到的额外代码是搜索当前不存在的分类,如果存在则不显示表单(设置如下)。
谢谢,
查尔斯
【问题讨论】: