Belch
12-13-2005, 08:27 AM
Sorry to ask for more info but got another problem I could use some help with.
I am trying to add a text box (with text hardcoded in it) to the second page of a document. I recorded a macro to do this (when it comes to autoshapes I try to stay away from manual coding!) but when I run the macro it adds the text box in the right position - but on the wrong page.
Below is the code:
Public Sub PutTextBoxOnPage()
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 171.3, _
410, 245.7, 31.5).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.Font.Name = "Arial"
Selection.Font.Name = "Arial"
Selection.Font.Size = 10
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeText Text:="THE TEXT GOES HERE"
Selection.ShapeRange.Select
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementTop -149.8
Selection.ShapeRange.Fill.Visible = msoFalse
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.Height = 19.45
Selection.ShapeRange.Width = 245.5
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.LockAnchor = False
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 5
End Sub
All I need to do is get the box to appear on the second page (in the same position on the page). I'm guessing it's the AddTextBox method that needs changing or perhaps one of the Relative...Position methods. I just can't see any way of telling it to put the textbox on page two not page one.
Any hints welcome, cheers.
I am trying to add a text box (with text hardcoded in it) to the second page of a document. I recorded a macro to do this (when it comes to autoshapes I try to stay away from manual coding!) but when I run the macro it adds the text box in the right position - but on the wrong page.
Below is the code:
Public Sub PutTextBoxOnPage()
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 171.3, _
410, 245.7, 31.5).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.Font.Name = "Arial"
Selection.Font.Name = "Arial"
Selection.Font.Size = 10
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeText Text:="THE TEXT GOES HERE"
Selection.ShapeRange.Select
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementTop -149.8
Selection.ShapeRange.Fill.Visible = msoFalse
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.Height = 19.45
Selection.ShapeRange.Width = 245.5
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.LockAnchor = False
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 5
End Sub
All I need to do is get the box to appear on the second page (in the same position on the page). I'm guessing it's the AddTextBox method that needs changing or perhaps one of the Relative...Position methods. I just can't see any way of telling it to put the textbox on page two not page one.
Any hints welcome, cheers.