Extract images from Publisher file

I

Ildhund

I have inherited a picture archive from the previous editor of a local
newspaper. This archive takes the form of several large Publisher 2003 files
each with hundreds of images. Each image is, I think, grouped with a text
box containing a caption. Some of these captions are quite wordy. The
pictures are probably all jpgs, placed at full size and then resized in
Publisher to fit the space available.

I would like to produce a macro that would extract each picture as a
separate file, something like
(a) open a specified Publisher file in a particular folder
(b) create a new folder with the same name as the Publisher file
(c) find each instance of an image grouped with a text box
(d) ungroup the two objects
(e) select the first, say, 25 characters of the text in the text box having
converted any line breaks to spaces
(f) reset the image to 100%
(g) save the image as .jpg with (e) as its file name in folder (b)
(h) regroup the objects
(i) close the file without saving changes.

I can manage some of this, but I can't find either Reset to 100% or a Save
As Picture method for a shape object like there is in the UI. Am I
attempting the impossible? If so, can anyone suggest a method of extracting
these images?

I'm using Office 2003 on XPSP2.
 
E

Ed Bennett

Ildhund said:
I can manage some of this, but I can't find either Reset to 100% or a Save
As Picture method for a shape object like there is in the UI. Am I
attempting the impossible? If so, can anyone suggest a method of extracting
these images?

It is possible, but not directly - you have to be tricky. The
PictureFormat object has an EffectiveResolution property; scale the
picture by 300 / EffectiveResolution and then export at 300dpi and you
will get the image at roughly its original resolution.

To save as a picture, copy and paste the image into a new publication,
change the page setup so that it fits the image snugly, and set the
image to be at (0, 0). Then Page.SaveAsPicture. Recompression will
occur, annoyingly, but there's not much that can be done about that
(unless you can learn the Publisher file format enough that you can hack
the images directly out of the files).
 
I

Ildhund

Ed Bennett wrote...
It is possible, but not directly - you have to be tricky. The
PictureFormat object has an EffectiveResolution property; scale the
picture by 300 / EffectiveResolution and then export at 300dpi and you
will get the image at roughly its original resolution.

To save as a picture, copy and paste the image into a new publication,
change the page setup so that it fits the image snugly, and set the image
to be at (0, 0). Then Page.SaveAsPicture. Recompression will occur,
annoyingly, but there's not much that can be done about that (unless you
can learn the Publisher file format enough that you can hack the images
directly out of the files).

Thanks, Ed. I'll give it a go, but be prepared for further silly questions
when I get stuck ;)
Does the source document have to be open for code to work on it?
 
E

Ed Bennett

Ildhund said:
Thanks, Ed. I'll give it a go, but be prepared for further silly questions
when I get stuck ;)
Does the source document have to be open for code to work on it?

If you're running a macro within the document, yes. If you're driving it
externally, then it has to be opened by the code you're running.
 
I

Ildhund

Ed Bennett wrote...
Ildhund wrote:

If you're running a macro within the document, yes. If you're driving it
externally, then it has to be opened by the code you're running.

Thanks.
 

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