R
Roderick O'Regan
I'm getting a VBA error which I cannot fathom out why it's happening.
Here's what I'm doing:
I create a document and run the following code to create a large white
box in a deep top margin of 10cm (that's what client wants!)
ActiveDocument.Shapes.AddShape(msoShapeRectangle, 10, 50, 10,
10).Select
With Selection.ShapeRange
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = CentimetersToPoints(3)
.Top = CentimetersToPoints(1.98)
.Width = CentimetersToPoints(17.5)
.Height = CentimetersToPoints(7.4)
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Line.Visible = msoFalse
.LockAnchor = True
.WrapFormat.AllowOverlap = True
.WrapFormat.Type = 3
.ZOrder msoSendBehindText
End With
Selection.Collapse
Within this white box goes a single cell table in which the user has
to type a title.
I then add another section and repeat the code above but the following
error appears:
"The RelativeHorizontaPosition method or property is not available
because the drawing operation cannot be applied to the current
selection" (It's error 4605)
Here's the weird bit:
If I don't type a title in the table contained in the first section I
can add the box OK in the second.
If I do add that title then try and run the code again in the second
section I get the error.
Can anyone suggest why I'm getting this error, please? And then only
in certain circumstances?
Roderick
Here's what I'm doing:
I create a document and run the following code to create a large white
box in a deep top margin of 10cm (that's what client wants!)
ActiveDocument.Shapes.AddShape(msoShapeRectangle, 10, 50, 10,
10).Select
With Selection.ShapeRange
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = CentimetersToPoints(3)
.Top = CentimetersToPoints(1.98)
.Width = CentimetersToPoints(17.5)
.Height = CentimetersToPoints(7.4)
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Line.Visible = msoFalse
.LockAnchor = True
.WrapFormat.AllowOverlap = True
.WrapFormat.Type = 3
.ZOrder msoSendBehindText
End With
Selection.Collapse
Within this white box goes a single cell table in which the user has
to type a title.
I then add another section and repeat the code above but the following
error appears:
"The RelativeHorizontaPosition method or property is not available
because the drawing operation cannot be applied to the current
selection" (It's error 4605)
Here's the weird bit:
If I don't type a title in the table contained in the first section I
can add the box OK in the second.
If I do add that title then try and run the code again in the second
section I get the error.
Can anyone suggest why I'm getting this error, please? And then only
in certain circumstances?
Roderick