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 / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Can images be named and then searched for?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kiln - 19 Nov 2005 18:55 GMT
Is there any mechanism for naming images (shapes, inline shapes,
whatever, I'm not actually clear on the difference between them). I'd
like to be able to loop through the images in a doc and see if a certain
one has been inserted. The image that I'd be looking for would have been
added via code, so I have the oppty to enforce the name of the object,
if that's possible.

Thanks
Jezebel - 19 Nov 2005 21:25 GMT
Shapes yes, InlineShapes no. However inline shapes can be bookmarked, so you
could name them that way. The difference between Shapes and InlineShapes: in
the document it refers to the Wrapping style (on the Format > Object >
Layout style tab). 'Inline with text' vs all the others. Inline shapes are
handled as part of the paragraph to which they are anchored; non-inline
shapes are floating. In VBA, the difference is that they are in different
collections (ActiveDocument.Shapes, ActiveDocument.InlineShapes).

Objects in the Shapes collection have names, which you can change --

Dim pShape as Shape
Set pShape = ActiveDocument.Shapes.AddPicture(FileName:=...)
pShape.Name = "La Joconde"

> Is there any mechanism for naming images (shapes, inline shapes,
> whatever, I'm not actually clear on the difference between them). I'd
[quoted text clipped - 4 lines]
>
> Thanks
kiln - 19 Nov 2005 21:47 GMT
OK, thanks, that clarifies a couple of items for me, I'll see what I can
make of them.

One question, could you give me a one or two liner, sample code, how an
inline shape can be bookmarked?

> Shapes yes, InlineShapes no. However inline shapes can be bookmarked, so you
> could name them that way. The difference between Shapes and InlineShapes: in
[quoted text clipped - 18 lines]
> >
> > Thanks
Jezebel - 19 Nov 2005 23:22 GMT
Dim pInlineShape As InlineShape

Set pInlineShape =
ActiveDocument.InlineShapes.AddPicture(FileName:="...\guernica.jpg")
ActiveDocument.Bookmarks.Add Name:="Guernica", Range:=pInlineShape.Range

> OK, thanks, that clarifies a couple of items for me, I'll see what I can
> make of them.
[quoted text clipped - 29 lines]
>> >
>> > Thanks
kiln - 20 Nov 2005 01:33 GMT
Thank you..to complete my education...is there any way to tell by
looking at a doc or the images properties if a visible image is a shape,
or an inline shape? And can an inline shape be "named" manually?

Thanks

> Dim pInlineShape As InlineShape
>
[quoted text clipped - 32 lines]
> >> > been
> >> > added via code, so I have the oppty to enforce the name of the object,
kiln - 20 Nov 2005 01:51 GMT
OK, on rereading you've already told me that it's the layout wrapping
style that determines if it's an inline shape or just a shape. I see
that I can switch from one type to another. This is really helpful. Next
I'll see if I can rename a shape in vba. Thanks!

> Thank you..to complete my education...is there any way to tell by
> looking at a doc or the images properties if a visible image is a shape,
[quoted text clipped - 32 lines]
> > >>
> > >> "kiln" <kiln@brick-like.com> wrote in message
Jezebel - 20 Nov 2005 02:43 GMT
Also note that there's a mistake in the documentation: it says that the add
methods of the InlineShapes collection (like AddPicture) return a Shape
object. This is incorrect. They return an InlineShape object.

> OK, on rereading you've already told me that it's the layout wrapping
> style that determines if it's an inline shape or just a shape. I see
[quoted text clipped - 46 lines]
>> > >>
>> > >> "kiln" <kiln@brick-like.com> wrote in message
Jay Freedman - 20 Nov 2005 02:01 GMT
If you select a picture in the document, it's an inline shape if:

- its sizing handles are black squares
- when you drop down the Wrapping menu on the Picture toolbar, or go
 to the Format Picture dialog and click the Layout tab, the
 "In Line With Text" item is selected
- when you drag it, you get the same kind of mouse pointer as when you
  drag text, and no dashed outline

It's a shape if:

- its sizing handles are black circles with white centers, and there
 is a green rotation handle attached to the top edge
- when you drop down the Wrapping menu on the Picture toolbar, or go
 to the Format Picture dialog and click the Layout tab, any item
 *except* "In Line With Text" item is selected
- when you drag it, you get a four-headed arrow mouse pointer and a
 dashed outline

The method for manually naming an inline shape is the analogue of the
VBA method Jezebel described: select the shape, go to Insert >
Bookmark, and enter the name. The name actually belongs to the
bookmark, not to the picture itself, but the distinction isn't
important if all you use it for is to go to it.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Thank you..to complete my education...is there any way to tell by
>looking at a doc or the images properties if a visible image is a shape,
[quoted text clipped - 38 lines]
>> >> > been
>> >> > added via code, so I have the oppty to enforce the name of the object,
Helmut Weber - 19 Nov 2005 21:30 GMT
Hi,

>Is there any mechanism for naming images (shapes, inline shapes,
>whatever, I'm not actually clear on the difference between them). I'd
>like to be able to loop through the images in a doc and see if a certain
>one has been inserted. The image that I'd be looking for would have been
>added via code, so I have the oppty to enforce the name of the object,
>if that's possible.

no, don't think so.

Unless you have inserted a linked picture,
like this:

Sub Macro2()
  Selection.InlineShapes.AddPicture FileName:= _
     "C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Blue hills.jpg" _
     , LinkToFile:=True, SaveWithDocument:=False
End Sub

After that, the picture has a linkformat-property,
possible to search for, either
SourceName or SourceFullName

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
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.