remove image from file with vba

M

mariolos

hello, any know how I can remove a picture from file (.doc) with vba
code??
( i dont know the name of picture to remove)

thx in adv.
 
J

Jonathan West

hello, any know how I can remove a picture from file (.doc) with vba
code??
( i dont know the name of picture to remove)

thx in adv.

You need some means of identifying the picture. Is it "floating" or
"inline"? The method required is different in the two cases. Is the picture
the only one in the document? If not, what method is available to work out
which is the right one? Is it the only one on the first page for instance?

Once you have a completely unmistakable way of identifying the right
picture, it is not hard to delete it. But we need to work first on
identifying it.
 
M

mariolos

You need some means of identifying the picture. Is it "floating" or
"inline"? The method required is different in the two cases. Is the picture
the only one in the document? If not, what method is available to work out
which is the right one? Is it the only one on the first page for instance?

Once you have a completely unmistakable way of identifying the right
picture, it is not hard to delete it. But we need to work first on
identifying it.



thx.

-My picture is inline
-Is the only one Picture in my document.
- Only in the first page.

thx again
 
J

Jonathan West

thx.

-My picture is inline
-Is the only one Picture in my document.
- Only in the first page.


In that case, one line of code will remove the picture, as follows

ActiveDocument.Range.InlineShapes(1).Delete
 
M

mariolos

ok, thx this works!!!

and last questions, with vba i cant know the name of my inline
picture, (by example my_pict.jpg?)
 
F

fumei via OfficeKB.com

and last questions, with vba i cant know the name of my inline
picture, (by example my_pict.jpg?)


Nope. It is an InlineShape, it has no name like my_pict.jpg
 
J

Jonathan West

ok, thx this works!!!

and last questions, with vba i cant know the name of my inline
picture, (by example my_pict.jpg?)

Once a picture has been inserted, unless you have inserted it as a link, no
record is kept of the name of the file from which it came. The file might
not have had a name if for instance the picture was pasted from the
clipboard.
 

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