Moving a Frame in a Word document

J

JayM

I have a couple of hundred documents that have 2 text frames in them.

One of the text frames needs to be moved and I wondered if there was anyway
of writing some vba to reference the text frame and position it some where
else?

Any help on this would be most gratefully received.

Many thanks
Jay
 
G

Greg Maxey

Perhaps something like this:

Sub ScratchMaco()
Dim oFrm As Word.Frame
Set oFrm = ActiveDocument.Frames(1)
With oFrm
.HorizontalPosition = 72
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.HorizontalDistanceFromText = 12
.VerticalPosition = 72
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.VerticalDistanceFromText = 12
End With
End Sub
 
J

Jonathan West

JayM said:
I have a couple of hundred documents that have 2 text frames in them.

One of the text frames needs to be moved and I wondered if there was
anyway
of writing some vba to reference the text frame and position it some where
else?

Any help on this would be most gratefully received.

Many thanks
Jay

OK, we need to break this down into smaller chunks before the problem can be
adequately defined.

1. Are all the documents in the same folder? Are any documents also in the
folder that you don't want processed?

2. Can you provide a description of the frame that will enable VBA code to
reliably identify the correct frame to be moved? (By the way, are we dealing
with a TextBox or a Frame? They are two different beasts which perform a
similar function.)

3. Can you provide a description that unambiguously defines where the frame
is to be moved to?


Assuming all the files are in the dame folder, the batch-processing part of
it is fairly easy. The following article describes how to do this

Find & ReplaceAll on a batch of documents in the same folder
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

Once we have an unambiguous description for items 2 & 3, the code for that
would replace the find/replace code on the inside of the loop in the code
sample in that article.
 
J

JayM

Greg / Jonathan

Many thanks fr your quick response. I had almost got there wit the changes
to the text frame but couldn't work out how to select the frame in the first
place - thanks Greg for your help with that.

Jonathan the link you gave me is fab and I have worked out now how to do a
replace all for a folder which saves so much time but what can i do if not
all the documents need to be changed. I would hope that none of the other
documents would have a text frame in (and yes it is a frame rather than a
box) but you can never really be sure.

If you have any ideas on this then I would be everso grateful, else I will
just go through each one and run my macro to do the changes in each one.

Thanks again both for your help it is so much appreciated.

Jay
 
J

Jonathan West

JayM said:
Greg / Jonathan

Many thanks fr your quick response. I had almost got there wit the
changes
to the text frame but couldn't work out how to select the frame in the
first
place - thanks Greg for your help with that.

Jonathan the link you gave me is fab and I have worked out now how to do a
replace all for a folder which saves so much time but what can i do if not
all the documents need to be changed. I would hope that none of the other
documents would have a text frame in (and yes it is a frame rather than a
box) but you can never really be sure.

There are two waus of going about this.

1. If there is some means by which you can write code to identify documents
that need not be processed, you include that code in the loop, and close the
document without saving before you go on to the next.

2. If you can't manage option #1 but can identify the right documents by
looking at them, then copy the documents you need to a separate folder, and
then process the batch there, and copy them back afterwards..
 

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