R
Roderick O'Regan
The following snippet is part of a larger procedure which places
AutoText graphics in a header and then moves them to the correct
location:
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
'enters the autotext graphic located in the attached Template
ActiveDocument.AttachedTemplate.AutoTextEntries(pString).Insert _
Where:=Selection.Range, RichText:=True
'first select the graphic
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.ShapeRange.Select
With Selection.ShapeRange
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = CentimetersToPoints(2.5)
.Top = CentimetersToPoints(1.99)
.WrapFormat.AllowOverlap = True
End With
If I run the template all works correctly.
However, if I open the template and then run this procedure to test
the code I get an error 4605 telling me that the
"RelativeHorizontralPosition method or property is not available
because the drawing operation cannot be applied to the current
selection"
The graphic (ShapeRange) is shown as selected.
I then Exit at the error message dialog, close the Header/Footer view
and try it again. It now works correctly from the second time onwards.
Could someone explain why this is happening, please?
Roderick O'Regan
AutoText graphics in a header and then moves them to the correct
location:
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
'enters the autotext graphic located in the attached Template
ActiveDocument.AttachedTemplate.AutoTextEntries(pString).Insert _
Where:=Selection.Range, RichText:=True
'first select the graphic
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.ShapeRange.Select
With Selection.ShapeRange
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = CentimetersToPoints(2.5)
.Top = CentimetersToPoints(1.99)
.WrapFormat.AllowOverlap = True
End With
If I run the template all works correctly.
However, if I open the template and then run this procedure to test
the code I get an error 4605 telling me that the
"RelativeHorizontralPosition method or property is not available
because the drawing operation cannot be applied to the current
selection"
The graphic (ShapeRange) is shown as selected.
I then Exit at the error message dialog, close the Header/Footer view
and try it again. It now works correctly from the second time onwards.
Could someone explain why this is happening, please?
Roderick O'Regan