2013-09-24 48 views
0

我正在研究用戶可以從Sharepoint訪問的Word模板。 在這個模板中,我用定製的UI編輯器製作了一個自定義功能區。在SharePoint的Word模板中使用宏更改標頭

我希望用戶能夠選擇頁眉和頁腳。 爲此,我已經制作了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打開模板。) 當我工作localy並將鏈接更改爲本地位置時,沒有任何問題。

有人可以幫我嗎? 感謝 尼娜

(我使用Word 2013,但也較老版本的Word必須能夠使用的文檔)。

回答

0

問題解決了。我將鏈接更改爲:Application.Templates(_ ActiveDocument.AttachedTemplate.FullName). _ 現在,它完美的工作!