> So, having selected an image to work with, how do I
> then select the text box immediately below it on the page? I can locate the
> text box roughly by starting at .Top and .Left, Increment by .Height + 5 and
> .Width/2, but how do I select the object at that position on the page, given
> that there is only one?
Iterate through all the text boxes on the page, and check which one has
the correct values of Top and Left?
A way to prevent this difficulty in future would be to add a pair of
tags to each shape pair with a unique ID. For example, add a tag called
"associateID" with a unique identifier as its value, and another tag
with its name as the unique identifier, to both the picture and the text
box. Then you can easily find the associated text box for a picture and
vice-versa using
ThisDocument.FindShapesByTag(aPicture.Tags("associateID").Value)

Signature
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
Ildhund - 13 Feb 2008 17:27 GMT
Ed Bennett wrote...
>> So, having selected an image to work with, how do I then select the text
>> box immediately below it on the page? I can locate the text box roughly
[quoted text clipped - 4 lines]
> Iterate through all the text boxes on the page, and check which one has
> the correct values of Top and Left?
Good idea, thanks. Because the text boxes aren't precisely placed, I'll have
to introduce some margin of error and hope I hit the right one. And
*another* iteration is going to slow this down even more, but that's not a
problem (yet!).
> A way to prevent this difficulty in future would be to add a pair of tags
> to each shape pair with a unique ID. For example, add a tag called
[quoted text clipped - 3 lines]
> vice-versa using
> ThisDocument.FindShapesByTag(aPicture.Tags("associateID").Value)
I can't imagine ever having to do this again, so I hope there is no "in
future.
Thanks again.

Signature
Noel"
Ed Bennett - 13 Feb 2008 19:50 GMT
> Good idea, thanks. Because the text boxes aren't precisely placed, I'll have
> to introduce some margin of error and hope I hit the right one. And
> *another* iteration is going to slow this down even more, but that's not a
> problem (yet!).
Once the code's written, surely you'll only have to iterate through once?

Signature
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
Ildhund - 13 Feb 2008 20:58 GMT
Ed Bennett wrote...
>> Good idea, thanks. Because the text boxes aren't precisely placed, I'll
>> have to introduce some margin of error and hope I hit the right one. And
>> *another* iteration is going to slow this down even more, but that's not
>> a problem (yet!).
>
> Once the code's written, surely you'll only have to iterate through once?
Sure, but there are dozens of pages in each of dozens of files and dozens of
pictures on each page. For each page I have to cycle through the objects; if
it's a group, copy it to This document, ungroup it and check that it's one
picture + one text box and process them. If it's not a group, cycle through
the text boxes to find the right one, extract its text, then copy the
picture to This document...
OK, it's not these iterations that are taking time; it's largely
SaveAsPicture, but the resizing is not instantaneous, either, even with
screen updating off. I'll cope. I understand all the original image files
have been jettisoned because "they're all in the Publisher files". Ha hum.

Signature
Noel
Ed Bennett - 13 Feb 2008 23:37 GMT
> I understand all the original image files
> have been jettisoned because "they're all in the Publisher files". Ha hum.
I feel your pain!

Signature
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org