Error using Macro recording

H

Holuigue

I need to frequently add a header (first page only)
I went through the process of recording a Macro, but when running it, I get
the following error message;

Run-time error '5941'
The requested member of the collection does not exist.

Not funny, since, as a first step, I picked a header in the "Built-in"
collection.

The code generated is as follows:
Sub Header()
'
' Header Macro
'
'
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
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Alphabet").Insert _
Where:=Selection.Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveWindow.Close
Application.Quit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top