【问题标题】:Change header with macro in Word Template on SharePoint在 SharePoint 上的 Word 模板中使用宏更改标题
【发布时间】:2013-09-29 12:24:00
【问题描述】:

我正在开发用户可以从 Sharepoint 访问的 Word 模板。 在这个模板中,我使用自定义 ui 编辑器制作了一个自定义功能区。

我希望用户能够选择页眉和页脚。 为此,我已经制作了 2 个不同的标题(1 个带有字段,1 个没有)并将它们保存在模板中。 因此,当我想插入标题时,我可以像这样选择它们:插入 --> 标题 --> 一直向下滚动到“模板”并选择其中一个。这很完美。我已经记录了这个过程的宏,所以我可以在我的自定义功能区上使用它。

宏如下所示:

Sub Header()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Application.Templates( _
    "http://spf.mysite.be/Shared%20Documents/Template.dotm"). _
    BuildingBlockEntries("Header").Insert Where:=Selection.Range, _
     RichText:=True
Selection.MoveDown Unit:=wdLine, count:=4
Selection.Delete Unit:=wdCharacter, count:=1
Selection.Delete Unit:=wdCharacter, count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

问题: 当我从 sharepoint 打开模板时,此宏不再起作用。 我认为这是因为 Word 更改了链接模板。当我转到开发人员选项卡并单击“文档模板”时,链接的模板如下:“C:\Users\xxx\AppData\Local\Temp\TemplateATA-8.dotm”(下一个 8 变为 9当我从 SharePoint 打开模板时。) 当我在本地工作并将链接更改为本地位置时,没有问题。

有人可以帮帮我吗? 谢谢 妮娜

(我使用的是 Word 2013,但旧版本的 Word 也必须能够使用该文档。)

【问题讨论】:

    标签: templates sharepoint macros header


    【解决方案1】:

    问题解决了。我将链接更改为:Application.Templates( _ ActiveDocument.AttachedTemplate.FullName). _ 现在完美运行了!!

    【讨论】:

      猜你喜欢
      • 2015-06-09
      • 1970-01-01
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多