Hi, i have a visual basic code that want to set header. But when i run the code,

WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF TI_MARKER", Preserveformatting:=True

i got an error message: "Error #: 91 - Object variable or With block variable not set "

I do have Set WAP = CreateObject("Word.Application"). Can somebody help me.

The source code is in the following:
Public Sub Set_Header()

On Error GoTo Err_Click

WAP.Selection.HomeKey unit:=wdStory
WAP.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
WAP.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
WAP.Selection.ParagraphFormat.SpaceAfter = 6
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF TI_MARKER", _
Preserveformatting:=True
WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF ST_MARKER", _
Preserveformatting:=True
WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF CH_MARKER", _
Preserveformatting:=True
'WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF RT_MARKER\l", _
Preserveformatting:=True


WAP.ActiveWindow.ActivePane.View.NextHeaderFooter
WAP.Selection.ParagraphFormat.SpaceAfter = 6
WAP.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF TI_MARKER", _
Preserveformatting:=True
WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF ST_MARKER", _
Preserveformatting:=True
WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF CH_MARKER", _
Preserveformatting:=True
'WAP.Selection.TypeText "."
WAP.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="STYLEREF RT_MARKER", _
Preserveformatting:=True
WAP.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Exit_Set_Header:
Exit Sub
Err_Click:
MsgBox "Error #:" & Err.Number & "--" & Err.Description

End Sub