
Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
> I have created a template that includes the insertion of a text box.
> I am using Word 2004 (Mac) and the template is to be used on PCs.
[quoted text clipped - 24 lines]
> or footer. How can I stop him from trying to run this macro in
> anything other than Page Layout view?
I meant to add this bit before sending my response:
It's probably a better idea to avoid selecting things and working with the
Selection object altogether, if that's possible. There are only a few things
you can do with the Selection that can't be done with Range objects and
other objects.
You'd start by declaring a Shape object
Dim myTextBox as Shape
and assign the result of the .AddTextbox method to it; use the Anchor
parameter to specify the anchor location from which the Left and Top are
measured:
Set myTextBox = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=42.55, Top:=667.65, _
Width:=340#, Height:=69#, _
Anchor:=ActiveDocument.Paragraphs(1).Range)
Then you can manipulate the myTextBox object in any way you need to -- add
text, format the TextFrame, etc. -- all without touching the Selection. It
won't matter what's in the active window, view, or pane.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
> Hi Oz,
>
[quoted text clipped - 44 lines]
>> or footer. How can I stop him from trying to run this macro in
>> anything other than Page Layout view?
Oz Springs - 21 Dec 2004 17:12 GMT
Hi Jay
Thank you very for your help. I haven¹t checked it out yet, but can you
confirm that you have set the textbox anchor to the first paragraph so that
it won¹t move around? If so, this is a bonus because I was going to set it
to stay put and you have saved me the bother of sorting that out as well.
Kind regards
Oz
On 21/12/04 16:43, in article uuet#w35EHA.828@TK2MSFTNGP14.phx.gbl, "Jay
Freedman" <jay.freedman@verizon.net> wrote:
> I meant to add this bit before sending my response:
>
[quoted text clipped - 20 lines]
> text, format the TextFrame, etc. -- all without touching the Selection. It
> won't matter what's in the active window, view, or pane.
Jay Freedman - 21 Dec 2004 18:28 GMT
Hi Oz,
Actually, I chose to anchor the textbox in the first paragraph because
that's a simple thing to do in an example. You can choose any spot in the
document that suits your needs.
The relationship between an object's position and its anchor is more than a
little strange. The only hard-and-fast rule is that the object must be on
the same page as the anchor. If text is added before the anchor range that
moves the anchor to the next page, the object will also jump to the next
page.
Within that restriction, there's no foolproof way to lock to location of the
object on that page. If you "lock the anchor" either programmatically or
through the Format Object dialog, you prevent only the movement of the
anchor from one paragraph to another; the object itself can still be dragged
to a new position on the page.
If you want the object to stay on the first page (or the first page of any
particular section), you can anchor it in the First Page Header instead of
the regular text (the object's position can still be anywhere on the page).
That will put it mostly out of harm's way -- the user will have to go to
some trouble just to select it. As a further protection, you can write
macros to (mostly) prevent user access to the header (see
http://word.mvps.org/FAQs/Customization/ProtectWord2000PlusHeader.htm)
unless their security setting disables macros.
That may be more than you really wanted to know, but some day you'll need
it. ;-)

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
> Hi Jay
>
[quoted text clipped - 35 lines]
>> Selection. It won't matter what's in the active window, view, or
>> pane.
Oz Springs - 21 Dec 2004 20:40 GMT
Thank you for this information. It should be safer to put the anchor on the
top paragraph mark in order to stop it moving up and down if text above it
changes, though this is not guaranteed.
It would be good if Microsoft could make text boxes less fragile, especially
for people creating templates, such as this one, to be used by many people
who don¹t know Word and its idiosyncrasies.
Text box text can¹t be seen in galley view and it is so easy to just delete
it without knowing you have done so (oh, these blank paragraph marks look so
messy...). Also, we should be able to ³lock² a text box in a position and on
a particular page without relying on those moveable paragraph marks. This
template will be used on a pre-printed, single page form and the text box
has to rest upon a stripe of colour. Otherwise I¹d avoid text boxes like the
plague in templates.
Wouldn¹t it be nice if Microsoft found a way of fixing this problem?
Many thanks
Oz
On 21/12/04 18:28, in article OyXfPr45EHA.4004@tk2msftngp13.phx.gbl, "Jay
Freedman" <jay.freedman@verizon.net> wrote:
> Hi Oz,
>
[quoted text clipped - 25 lines]
> That may be more than you really wanted to know, but some day you'll need
> it. ;-)