Need your help, macro run time error 5941.

Joined
Apr 1, 2009
Messages
2
Reaction score
0
Hello..

I have created a macro that insert my name as a left-aligned header and the document name "Collaboration tools" as a right-aligned header on every page except the title page. And assigned keyboard command "Ctrl + Alt + H" to the macro. However i was giving a runtime error 5941 when i tried to tun the macro.

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( _
" Blank (Three Columns)").Insert Where:=Selection.Range, RichText:=True

Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Eric"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeBackspace
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="Collaboration tools"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


Here is the problem:

ActiveDocument.AttachedTemplate.BuildingBlockEntries( _
" Blank (Three Columns)").Insert Where:=Selection.Range, RichText:=True


can anyone help me overcome it ...

and thank you for viewing..
 

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

Top