View Single Post
 
Old 11-30-2017, 09:37 AM
LaurenM LaurenM is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

I found that if I group the two textboxes, they stay put. I need to do this via VBA, however. What is wrong with this code

Set shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=5, Width:=500, Height:=41)
shp.TextFrame.TextRange.Text = "Please add company name"
shp.TextFrame.TextRange.Style = oStyle
shp.Line.Visible = msoFalse
shp.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp.Top = InchesToPoints(1.1)
shp.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp.Left = InchesToPoints(0.27)
shp.Name = Shape1

Selection.GoTo What:=wdGoToPage, Which:=wdseekcurrent
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPage
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Set shp2 = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=5, Width:=500, Height:=41)
shp2.TextFrame.TextRange.Text = "Please add title"
shp2.TextFrame.TextRange.Style = bStyle
shp2.Line.Visible = msoFalse
shp2.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp2.Top = InchesToPoints(1.5)
shp2.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp2.Left = InchesToPoints(0.27)
shp2.Name = Shape2
With Selection.ShapeRange
.LockAnchor = True
End With

ActiveDocument.Shapes.Range(Array("Shape1", "Shape2")).Select
Selection.ShapeRange.Group

It doesn't group the two. Can anyone assist
Reply With Quote