Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Find the text box below an image

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ildhund - 13 Feb 2008 15:33 GMT
My macro to extract images from a Publisher file (see
news:OLr$77LaIHA.536@TK2MSFTNGP06.phx.gbl ) is working fine, thanks to Ed,
for cases where the image is grouped with a text box containing the caption.
I can use part of the caption as FileName and all of it as a Comment in the
File Properties.

However, while all images have their caption in a text box beneath the
picture, this pair of objects is not always grouped. When I cycle through
the objects on a page, I can see that sometimes the caption was placed first
and sometimes the image. 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?
Signature

Noel

Ed Bennett - 13 Feb 2008 16:08 GMT
> 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


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.