chris9104
09-08-2016, 03:25 AM
This is a section of code in a larger piece, but this section changes the header
If DrpHead.Value = "York" Then
ActiveDocument.ActiveWindow.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
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( _
"C:\Users\Chris\AppData\Roaming\Microsoft\Document Building Blocks\1033\15\Building Blocks.dotx" _
).BuildingBlockEntries("York").Insert Where:=Selection.Range, RichText:= _
True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End If
Keep getting an error on the section about choosing the application template, it works fine if I have manually added a header while the file is open, but errors if I run it without the manual change of header.
17049
If DrpHead.Value = "York" Then
ActiveDocument.ActiveWindow.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
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( _
"C:\Users\Chris\AppData\Roaming\Microsoft\Document Building Blocks\1033\15\Building Blocks.dotx" _
).BuildingBlockEntries("York").Insert Where:=Selection.Range, RichText:= _
True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End If
Keep getting an error on the section about choosing the application template, it works fine if I have manually added a header while the file is open, but errors if I run it without the manual change of header.
17049