Retrieve path of embedded graphic

S

Susanne Wenzel

Hi to everyone,

I've already found out that unfortunately vba in Publisher is quite limited
compared to other Office products, so I do not expect too much, but at
least I wanted to ask.

I want to find out the path of my embedded pictures.

I've tried this way:
http://support.microsoft.com/?id=199066

I know it was written for Access but I would think OLE-Objects (or am I not
dealing with OLE-Objects in Publisher?) are the same for every Office
application and I didn't find any specific Access-Code so I tried. But I
got runtime error 438 (I probably passed the wrong argument) so this did
not get me any further.

I'm not sure whether Graphics Manager which at least knows the filename of
the embedded pictures can help me (is this list accessible with vba?), I
did not see any connection between this featue and the Shapes-Listing. But
maybe I've simply overlooked something somewhere.

So is there a way (just anything, vb, api...) to get this information?

Any help would be appreciated.
Thanks for reading

Greetings
Susanne

Win2k, Publisher 2002 each on highest patch level
 
E

Ed Bennett

Susanne said:
I've already found out that unfortunately vba in Publisher is quite limited
compared to other Office products, so I do not expect too much, but at
least I wanted to ask.

There are some areas where Publisher's VBA is limited, but as a
Publisher VBA specialist I have found moving to Word and PowerPoint
challenging (particularly with respect to the degree with which pictures
are supported).
I know it was written for Access but I would think OLE-Objects (or am I not
dealing with OLE-Objects in Publisher?) are the same for every Office
application and I didn't find any specific Access-Code so I tried.

Access is the only application where linked pictures have to be stored
as OLE objects. All other Office applications have a more elegant solution.
But I
got runtime error 438 (I probably passed the wrong argument) so this did
not get me any further.

Suggestion 1 (if you haven't already looked there);
Check out the Publisher Object Model Reference. This is probably found at:
c:\<Program Files>\Microsoft Office\OFFICE11\1031\VBAPB10.CHM

(I'm not sure whether Program Files should be replaced with something
like 'Programmen' on German systems)

Suggestion 2:
Use the Type property of the Shape object to determine whether the shape
in question is a linked picture (if it is, the property will return
pbLinkedPicture. Alternatively, check the PictureFormat.IsLinked
property of the shape.

Once you have worked out whether the shape is a linked picture, you can
find the filename (including path) at PictureFormat.Filename.

Hope this helps!
 
S

Susanne Wenzel

Am Sun, 09 Jul 2006 19:39:13 +0100 schrieb Ed Bennett:
There are some areas where Publisher's VBA is limited, but as a
Publisher VBA specialist I have found moving to Word and PowerPoint
challenging (particularly with respect to the degree with which pictures
are supported).

Supported in Publisher vba? Or Word/Power Point vba?

I'm coming from the Excel/Word vba 'corner' and I couldn't believe that
Publisher does not have a start or startup folder where you can load your
macros so that you have them available for all open publications. I googled
and found someone who just wanted to know this and you said the only way to
achieve something close to this would be a ComAddIn...
I could do this having classic vb available but that is a bit of work. I
think this feature is really missing (maybe Publisher 2007 supports that?).

But I'm getting off-topic, sorry.
Suggestion 1 (if you haven't already looked there);
Check out the Publisher Object Model Reference. This is probably found at:
c:\<Program Files>\Microsoft Office\OFFICE11\1031\VBAPB10.CHM
(I'm not sure whether Program Files should be replaced with something
like 'Programmen' on German systems)

You are very close, it's 'Programme' ;-)
I just had a look, as soon as I find sometime, I'll deal with that more
deeply.
But...
Suggestion 2:
Use the Type property of the Shape object to determine whether the shape
in question is a linked picture (if it is, the property will return
pbLinkedPicture. Alternatively, check the PictureFormat.IsLinked
property of the shape.
Once you have worked out whether the shape is a linked picture, you can
find the filename (including path) at PictureFormat.Filename.

.... I'm pretty sure, I have embedded pictures. Graphics Manager says so and
the object type is 13 (pbPicture). The shape has a PictureFormat property
but nothing like PictureFormat.IsLinked. I'm getting rt error 438 by asking
this in the 'direct window' (?) again and in the 'watch window'(btw what
are the proper terms for those windows?) which usually sits in the lower
righthand corner of the IDE no property of the shape in question tells me
anything nearing a filename or a path. So I guess it's a more tedious work
to scratch that out.
Hope this helps!

It definitely did help a bit, thank you.
But as my pictures are not linked what else can I do?

Greetings
Susanne
 
E

Ed Bennett

Susanne said:
Supported in Publisher vba? Or Word/Power Point vba?

Supported far better in Publisher VBA. Word and PowerPoint does not give
you access to any information about the underlying image, only about the
frame. You have to copy and paste to a Publisher instance to get things
like pixel size.
I'm coming from the Excel/Word vba 'corner' and I couldn't believe that
Publisher does not have a start or startup folder where you can load your
macros so that you have them available for all open publications.

That's due to the lack of a normal.pub that behaves like Word's, I
think. You're welcome to post a suggestion; I would second it.
I googled
and found someone who just wanted to know this and you said the only way to
achieve something close to this would be a ComAddIn...

I remember suggesting that.
I could do this having classic vb available but that is a bit of work. I
think this feature is really missing (maybe Publisher 2007 supports that?).

Haven't seen it if it is, sorry.
But I'm getting off-topic, sorry.

Don't worry - we're still discussing Publisher programming :)
You are very close, it's 'Programme' ;-)
I just had a look, as soon as I find sometime, I'll deal with that more
deeply.

It's a good place to look for reference on what functions, properties,
etc. do what.
... I'm pretty sure, I have embedded pictures. Graphics Manager says so and
the object type is 13 (pbPicture). The shape has a PictureFormat property
but nothing like PictureFormat.IsLinked. I'm getting rt error 438 by asking
this in the 'direct window' (?) again and in the 'watch window'(btw what
are the proper terms for those windows?)

The first is the "Immediate" window. The latter is the Watch window,
where watches are set.
It definitely did help a bit, thank you.
But as my pictures are not linked what else can I do?

If the pictures aren't linked, then Publisher forgets about the source
file, as it embeds it in the publication. The original could be
modified, renamed or deleted and Publisher wouldn't know or care, so the
original file path might be of limited use anyway. To what end do you
need the path of the original image?
 
S

Susanne Wenzel

Am Sun, 09 Jul 2006 21:50:02 +0100 schrieb Ed Bennett:
Supported far better in Publisher VBA. Word and PowerPoint does not give
you access to any information about the underlying image, only about the
frame. You have to copy and paste to a Publisher instance to get things
like pixel size.

So that (among many other things) waits to be discovered...:)
That's due to the lack of a normal.pub that behaves like Word's, I
think. You're welcome to post a suggestion; I would second it.

Or just any workbook you save in the xlstart folder (in Excel).

It is strange to me that Publisher opens each publication in a different
instance, regarding it from the ide. Why? And Publisher does not support
command lines as far as I found out (I thought of forcing Publisher to open
a 'macro' publication every time it is started, but to no avail).

Well, what could one suggest? With all I've written above it is possible
the 'Redmonders' simply didn't think it would be needed (what a mistake!)
or it does not fit in with the concept of that programme. But I can't tell
that, I'm not familiar enough with Publisher to judge about that.

Alas, imho another feature is missing that you find in nearly every other
Office application and that's the macro 'recorder'.

[...]
If the pictures aren't linked, then Publisher forgets about the source
file, as it embeds it in the publication. The original could be
modified, renamed or deleted and Publisher wouldn't know or care, so the
original file path might be of limited use anyway.

Yes, that is a reasonable explanation. I've just recorded the same action
in Word and interesting enough I'm dealing with an inlineshape instead of a
shape object. And of course Word knows the path while inserting whereas
afterwards there is also no way of finding out...
To what end do you need the path of the original image?

I would like to sort of 'script out' my publication. So that when I have
all ingredients at hand I just run my macro and end up from a blank
publication to one that comes very near to my original publication. This
would also serve as some kind of storage. Plus it could help me as soon as
another picture is missing.

Do I have access to the Graphics Manager list via vba? At least this
feature knows and stores the filename of the picture, so I could start from
there.

I've got loads of other questions so I better stop this novel and myself
here.:)

Thanks again, your help is appreciated

Susanne

P.S.: I just wanted to mention one other thing: Thank you very much for
using 'internet style' to answer posts, this is very nice. Up to now I've
almost always seen posts from Americans making full quotes (answer above
and all the old rest underneath so it gets longer and longer, you just
scroll and scroll and scroll and no new information coming after the
signature). Of course you find 'full quoters' any other place but it seems
to me very common in the English community.
 
E

Ed Bennett

Susanne said:
It is strange to me that Publisher opens each publication in a different
instance, regarding it from the ide. Why?

It's a throwback to Publisher's heritage. Originally (or the earliest I
can remember), Word, Excel and PowerPoint were MDI (multiple document
interface) applications - they opened a main window, with individual
documents opened in child sub-windows within the main window. Publisher,
on the other hand, was always SDI (single document interface) - to open
a second document at the same time, you had to start a new instance of
Publisher. In Office 2000, Word, Excel and PowerPoint were moved to a
pseudo-SDI (where although a single application instance was used, the
application tried to look like an SDI application, as Redmond decided
that MDI was too 'confusing' for the clueless users they so like to
pander to. Unfortunately this caused a user interface disaster, which
was confusing for all users and inconsistent with pretty much all
Windows application design standards). Then in Publisher 2002, Publisher
was moved over to the same model, but because of Publisher's SDI
heritage, multiple instances were used instead (made the work easier).
Unfortunately this then made the interface not-quite-consistent with the
rest of office.
And Publisher does not support
command lines as far as I found out (I thought of forcing Publisher to open
a 'macro' publication every time it is started, but to no avail).

As in 'mspub.exe said:
Well, what could one suggest? With all I've written above it is possible
the 'Redmonders' simply didn't think it would be needed (what a mistake!)
or it does not fit in with the concept of that programme. But I can't tell
that, I'm not familiar enough with Publisher to judge about that.

I think it's more a case of the programmability features being added due
to popular demand, but not being implemented as fully as they could be
in other applications, due to insufficient time and/or manpower. If you
think Publisher 2003 VBA is lacking in features, you should take a look
at Publisher 2002 VBA. Ugh, that was horrible.
Alas, imho another feature is missing that you find in nearly every other
Office application and that's the macro 'recorder'.

This has been heavily demanded since Publisher 2002 was in beta (where
the VBA features were introduced). It still hasn't arrived.
Yes, that is a reasonable explanation. I've just recorded the same action
in Word and interesting enough I'm dealing with an inlineshape instead of a
shape object.

Because by default Word adds shapes as inline shapes instead of as
floating shapes. Inline shapes aren't supported in Publisher, for
obvious reasons (well, obvious to me, anyway).

If you were to change the picture so that it floated (by changing the
text wrap), it would change into a Shape object.
I would like to sort of 'script out' my publication. So that when I have
all ingredients at hand I just run my macro and end up from a blank
publication to one that comes very near to my original publication. This
would also serve as some kind of storage. Plus it could help me as soon as
another picture is missing.

Something along the lines of creating a template?
Do I have access to the Graphics Manager list via vba?

According to the Object Model reference, the Filename property of the
PictureFormat object should return the filename (without path) for
embedded pictures. Everything that is available in Graphics Manager
should be available under the PictureFormat object.
I've got loads of other questions so I better stop this novel and myself
here.:)

Feel free to ask all your questions, and I'll ramble incoherently in an
attempt to answer them.
Thanks again, your help is appreciated

Your questions are appreciated - this group is virtually empty most of
the time, and devoid of programming questions even more often.
P.S.: I just wanted to mention one other thing: Thank you very much for
using 'internet style' to answer posts, this is very nice. Up to now I've
almost always seen posts from Americans making full quotes (answer above
and all the old rest underneath so it gets longer and longer, you just
scroll and scroll and scroll and no new information coming after the
signature). Of course you find 'full quoters' any other place but it seems
to me very common in the English community.

It's less common in the main Usenet. Both Outlook Express and the
Microsoft Web newsgroup client encourage top-posting, so the uninitiated
tend to indulge in it without realising there's an alternative.

Although top-posting isn't as bad as bottom-posting without trimming
(which Thunderbird encourages, and I see quite a lot in some private
newsgroups).
 
S

Susanne Wenzel

Am Mon, 10 Jul 2006 14:30:23 +0100 schrieb Ed Bennett:

[explanation for having each publication seemingly in a new instance
snipped]
As in 'mspub.exe <document name>'?

Now I just tried to open it directly as you suggested it (before I just
tried to get a help text in the DOS-Box by printing mspub.exe /? or
mspub.exe /help and then Publisher just started with a blank publication)
and yes, you're right, it opens with my publication. But nevertheless this
is not leading any further. As soon as I open another publication in that
instance, when I turn to the IDE I only find the active publication and
therefore none of my macros. And there is no property such as
Application.Documents. It only knows Application.ActiveDocument, so I would
have some trouble in addressing the other publication (maybe with
GetObject? I don't know, I haven't tried yet. And I doubt it's worth the
effort.
[...] If you think Publisher 2003 VBA is lacking in features, you should
take a look at Publisher 2002 VBA. Ugh, that was horrible.

Thanks, Ed, you really encourage me.:)
I *am* dealing with Publisher 2002 VBA that's exactly what I've got
here...;-)
This has been heavily demanded since Publisher 2002 was in beta (where
the VBA features were introduced). It still hasn't arrived.

What about Publisher 2007?
But I fear that VBA is going to die rather soon and vba.net will be
replacing it.
Something along the lines of creating a template?

No, it wouldn't be a template or only in a rather vague way.
I really thought of scripting my 'layout'. Each day of my travel diary is
unique and cost lots of hours to have every object (pictures, textboxes and
the like) in size and place and background (and and and) the way I like it.
I wanted to read out the most important values of all my objects and store
them in a database just to have them handy.

A bit like what you can do in sqlserver. You create a table with all
constrainsts, all references, all fields, everything. And when you're ready
you can script it. Run that script on another database and you get exactly
your table a second time. Do you understand a bit what I'm trying to tell?
According to the Object Model reference, the Filename property of the
PictureFormat object should return the filename (without path) for
embedded pictures. Everything that is available in Graphics Manager
should be available under the PictureFormat object.

It should, but it isn't...:-/
My PictureFormat Object just offers me Application, Brightness, ColorType,
Contrast, CropBottom, CropLeft, CropRight, CropTop,
HorizontalPictureLocking, Parent, TransparencyColor, TransparentBackground
and VerticalPictureLocking. That's all there is.
Feel free to ask all your questions, and I'll ramble incoherently in an
attempt to answer them.

One other thing I stumbled across: ThisDocument knows the interesting
events ShapesAdded and ShapesRemoved, but just how can it be, that the
shape in question which fires the event is not handed over as an argument?

To grab the added shape I work with Shapes.Count but imho this can be only
called a workaround.

It seems to me I've got the wrong version for trying much with vba, right?
As you mentioned somewhere above...
Your questions are appreciated - this group is virtually empty most of
the time, and devoid of programming questions even more often.

Well, at least I've brought a little traffic in here if nothing else.:)

What would you advise me to do? Try with a ComAddIn?

That might get me my macros in every publication but it couldn't help much
to overcome the limitations of Publisher 2002 VBA I fear...

Thanks again
Susanne
 
E

Ed Bennett

Susanne said:
Thanks, Ed, you really encourage me.:)
I *am* dealing with Publisher 2002 VBA that's exactly what I've got
here...;-)

Oh no, I'm so sorry.

Publisher 2003 introduces a Documents collection. Still no Macro
Recorder, though. Not in 2007, either.
What about Publisher 2007?

Nope, sorry.
But I fear that VBA is going to die rather soon and vba.net will be
replacing it.

Nobody has seen any evidence of VBA.NET coming yet. I doubt it will be
introduced into Publisher in the same version release as the rest of
Office, anyway, so you have two more versions with VBA yet.
A bit like what you can do in sqlserver. You create a table with all
constrainsts, all references, all fields, everything. And when you're ready
you can script it. Run that script on another database and you get exactly
your table a second time. Do you understand a bit what I'm trying to tell?

Very vaguely...

I would probably accomplish this by creating a page at the end of the
file (or in another file) with the blank layout I want. Then select all,
group, copy and paste.

Are you looking to actually programmatically generate the script?
Otherwise, couldn't you get the file names manually?
It should, but it isn't...:-/
My PictureFormat Object just offers me Application, Brightness, ColorType,
Contrast, CropBottom, CropLeft, CropRight, CropTop,
HorizontalPictureLocking, Parent, TransparencyColor, TransparentBackground
and VerticalPictureLocking. That's all there is.

Check your Object Model reference. I can't remember whether Publisher
2002 provided access to this property. Lots of things that were
available in the GUI in Publisher 2002 were omitted from the Object
Model. Make sure you have SP3 for Office XP to make sure you have the
latest version (I think there may have been a couple of small updates
that make life slightly easier, although nowhere close to Publisher 2003).
One other thing I stumbled across: ThisDocument knows the interesting
events ShapesAdded and ShapesRemoved, but just how can it be, that the
shape in question which fires the event is not handed over as an argument?

To grab the added shape I work with Shapes.Count but imho this can be only
called a workaround.

Most definitely. The shape events found in all versions of Publisher
I've tried with so far are, in all honesty, pitiful. I'm going to be
clamouring for them for the next version of Publisher.
It seems to me I've got the wrong version for trying much with vba, right?
As you mentioned somewhere above...

Pretty much.
Well, at least I've brought a little traffic in here if nothing else.:)
:)

That might get me my macros in every publication but it couldn't help much
to overcome the limitations of Publisher 2002 VBA I fear...

That's exactly what I was about to post until I saw the extra sentence
of your post.

Using a COM Add-in has its own limitations, though.
 
S

Susanne Wenzel

Am Mon, 10 Jul 2006 23:14:46 +0100 schrieb Ed Bennett:
I would probably accomplish this by creating a page at the end of the
file (or in another file) with the blank layout I want. Then select all,
group, copy and paste.

It will probably come to that...
Are you looking to actually programmatically generate the script?

Yes, more or less. But I think I have to give this up.:-(
Otherwise, couldn't you get the file names manually?

Of course I could, but there are more than thousand (and Graphics Manager
has them, it seems so unfair...:)
Check your Object Model reference. I can't remember whether Publisher
2002 provided access to this property. Lots of things that were
available in the GUI in Publisher 2002 were omitted from the Object
Model.

Filename seems to be one of them, I just checked it up.
Make sure you have SP3 for Office XP to make sure you have the latest
version (I think there may have been a couple of small updates that make
life slightly easier, although nowhere close to Publisher 2003).

I have SP3.

And I have enjoyed our conversation.
Using a COM Add-in has its own limitations, though.

Not to mention the fun you have with commandbars and the like...

Thank you very much, I will try to make the most of the features available
to me

Greetings from Germany
Susanne
 

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