I'm using a VBA for Word macro that creates a series of shapes inside the headers and footers of the document. The last one that I create is a line shape in the header of page two. After the creation of this shape, I'd like to get back into the main document and continue on from there but I can't seem to make it happen. I get an error message that says, "This method or property is not available because the current selection is not in a header or footer." However, the shape is created in the header, so I don't understand why I'm getting this error message.
Here's the code I'm using :
'Create the shape and set it's properties
.Headers(wdHeaderFooterPrimary).Shapes.AddShape msoLine, 50, 40, 500, 1
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes(4).Select 'Select the shape
'Set the shape's properties
Selection.ShapeRange.Line.ForeColor = RGB(0, 0, 0) 'change line color to black
Selection.ShapeRange.Shadow.Type = msoShadow6
'Get back into the main document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
I've tried deselecting the shape in order to select the paragraph mark inside the header and I still get the same error message.
I'm stumped. Any advice or help is greatly appreciated!