Find name of a shape object

B

Brandon

Hello,

Using Word 2000.

I have inserted several picture files into a table on a Word Template. I am
looking to hide a picture if a certain text field is blank. I can't seem to
figure out the name of the picture file though, so I can reference it and
hide it. Is there any way to display the name of picture file as it is named
in VBA?

Thanks
Brandon
 
T

Tony Jollans

Pictures in Word do not have names. You can bookmark them to make them
identifiable but it is unclear from your post how you intend to relate
individual pictures to text fields.
 
O

old man

Hi,

First you have to figure out if its a shape object or inlineshape object. If
you are sure you are dealing with a shape object you can use the following
code:

Dim Shape1 As Shape

For Each Shape1 In ActiveDocument.Shapes

MsgBox Shape1.Name

Next

The default name for each shape is "Picture x" where x is a number from 1 to
n. The first inserted picture is usually named Picture 1...

The only way to assign a name to a shape is by using code such as:

Shape1.Name = "New name"

old man
 
O

old man

An Inline shape does not have a name and cannot be assigned a name. However
you can access a given picture (which is usually an inline shape) by either
checking the inlineshapes collection and figuring out (by its location) what
inline shape you want to delete or you can do the following:

1. Assign a bookmark to the picture
2. If a condtion exists if (some condition = true) then if the bookmark
exists
then delete the range denoted by the bookmark.

if some condition is true then
If ActiveDocument.Bookmarks.Exists("a1") = True Then
ActiveDocument.Bookmarks("a1").Range.Delete
End If
Endif

This wil delete the bookmark too.

old man
 

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