Hi All,
I’m hoping someone cam help me with this–I think it’s a simple problem, but I’m VB illiterate .
I’ve recorded variations of the macro below several times and none of them will run – I always get the same error message “Runtime error -2147024809 (80070057) – The item with the specified name wasn’t found.”
When I look at the code, I can see the problem, but can’t understand it. I don’t understand why the text box I’m trying to format has a number assigned to it. More importantly, I don’t know how to modify the code so it will work on any text box I wish to format.
The macro is below…
Any help is greatly appreciated!! Thanks in advance…
Bill
Sub FormTextBox()
‘
‘ FormTextBox Macro
‘
‘
ActiveDocument.Shapes(“Text Box 69”).Select <—- This is where the macro halts
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Left = 187.2
Selection.ShapeRange.Top = 432.7
Selection.ShapeRange.TextFrame.MarginLeft = 7.2
Selection.ShapeRange.TextFrame.MarginRight = 7.2
Selection.ShapeRange.TextFrame.MarginTop = 3.6
Selection.ShapeRange.TextFrame.MarginBottom = 3.6
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
Selection.ShapeRange.RelativeHorizontalSize = _
wdRelativeHorizontalSizeMargin
Selection.ShapeRange.RelativeVerticalSize = wdRelativeVerticalSizeMargin
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.LeftRelative = wdShapePositionRelativeNone
Selection.ShapeRange.Top = InchesToPoints(0)
Selection.ShapeRange.TopRelative = wdShapePositionRelativeNone
Selection.ShapeRange.WidthRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.HeightRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.LockAnchor = False
Selection.ShapeRange.LayoutInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0.1)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0.1)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = wdWrapTopBottom
Selection.ShapeRange.TextFrame.AutoSize = True
Selection.ShapeRange.TextFrame.WordWrap = True
Selection.ShapeRange.TextFrame.VerticalAnchor = msoAnchorTop
End Sub