problem creating macro to move textbox

S

Sandy

I trying to record a macro that will move a texbox that
is in a header. When I start recording the macro and go
into the header I am unable to select the textbox. I just
need to move the textbox from right align in the header to
left align. Is is possible to select a graphic while
recording a macro, my textbox is not in-line text.

Any suggestions would be greatly appreciated.

Thanks
 
G

Greg

Sandy,

Could you use a Frame (View>Toolsbars>Forms click the
frame icon and draw the frame) rather than a textbox?

You can select a textbox and while you can move it left,
unless it is of a constant dimension, I don't think you
can align it to the right margin.

The following macro takes a Frame(1) in the Header and
aligns the right edge with the right margin. You can
format a frame to look like text box.

Sub Macro1()
With ActiveWindow
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
If .ActivePane.View.Type = wdNormalView
Or .ActivePane.View.Type _
= wdOutlineView Then
.ActivePane.View.Type = wdPrintView
End If
..ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection.HeaderFooter.Range.Frames(1)
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
.HorizontalPosition = wdFrameRight
End With
End With

End Sub
 
S

Sandy

Unfortunately, the template was created with a textbox in
the header and we can't change it to a frame.


I'm sorry I didn't mean to left align it I meant a
horizontal alignment, to move the box to the left there is
an option in Format TextBox->Layout->Horizontal Alignment -
Left. Which I can do once I select the box but the
problem I'm running into is how to selected the textbox
through code, since I'm not able to click on it while
recording the macro.
 
G

Greg Maxey

Sandy,

Did you display the header and footer pane before attempting to select the
textbox? I have no problem recording a macro and selecting the box in the
header.

If you have just one textbox in the header, try:

Sub Macro1()

If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.HeaderFooter.Shapes(1).Select
.ShapeRange.Left = wdShapeLeft
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top