#  Other Applications & Softwares  > Word Formatting & General >  >  Remove unneeded images from a Word 2007 document

## gl2excel

Hello,

if I rename a Word 2007 .docx to .zip extension, I can see that the \word\media\ folder contains unused images, resulting in a file too big.

How to delete them from Word 2007 interface ?

Deleting the images from the zip file content, results in a corrupted word file.

Thank you.

----------


## macropod

You should be able to delete the images from the zip file. Word might complain when it tries to open the document, but it should open anyway. An alternative is to replace the zip file's images with smaller versions, to get the overall file size below 512Mb.

----------


## gl2excel

There's no way to do this from inside Word 2007 ?

----------


## macropod

If the file is too large to open in Word (i.e. > 512Mb), then quite clearly you can't do it from within Word...

----------


## gl2excel

In reality my file is less than one megabyte in size, I was just curious to know if there was a solution from within Word 2007 itself.

Removing the unneeded images from the zip file seems to work: after an error message, Word is able to "recover" the file.

----------


## macropod

> In reality my file is less than one megabyte in size, I was just curious to know if there was a solution from within Word 2007 itself.



In that case, why not just open the document and delete the image(s)? Unless you have 'Track Changes' on, that should be sufficient to delete the image from the file in its entirety. The only images you might then be unable to delete are those that someone has moved outside the page boundaries, and even those can be found and deleted.

----------


## gl2excel

> In that case, why not just open the document and delete the image(s)?



Because images are nowhere in the document and they are not outside the page boundaries.

----------


## macropod

> Because images are nowhere in the document and they are not outside the page boundaries.



And _how_ did you establish that?

----------


## gl2excel

> And _how_ did you establish that?



Because I can't see the images in the few pages of the document.

----------


## macropod

And, if they've been moved outside the page boundaries, you wouldn't see them...

----------


## gl2excel

> And, if they've been moved outside the page boundaries, you wouldn't see them...



What can I do to check if these images are outside the page boundaries ?

----------


## macropod

You could delete all shapes with a macro like:



```
Please Login or Register  to view this content.
```

----------


## gl2excel

This macro seems to have no effect on the document.

Probably what described earlier is a problem inherited from the original rtf file format that was later converted to docx.

Anyway, editing the zip file content seems to provide a solution to remove the unneeded images taking extra space.

----------


## macropod

> This macro seems to have no effect on the document.



In which case the images may have been in the header or footer - slightly different code would be needed for that.

----------


## gl2excel

> In which case the images may have been in the header or footer - slightly different code would be needed for that.



You are right, the images were in the header and footer, but I'm sure to have replaced them with other images, so I don't know why they are still in the \word\media\ folder.

----------


## macropod

If your document had 'Track changes' on when the content was deleted, it would still be there pending acceptance of those changes. For any other case, the following macro should do the job:



```
Please Login or Register  to view this content.
```

----------


## gl2excel

'Track changes' was never enabled on Word.

If I try to execute the new macro code, the script stops its execution with the following error:

"Compile error: Method or data member not found" with .ShapeRange highlighted and no specific error code.

----------


## macropod

Oops - instead of:
With HdFt
use:
With HdFt.Range

Code in previous post updated.

----------


## gl2excel

The script is now ok, but the images are still inside the file.

I fear that the rtf to word conversion may have some influence on the desired script functionality.

----------


## macropod

If there are images in the file after running both macros, either they're not in the body of the document or the headers/footers or change-tracking has been used. The file format and format conversion has nothing to do with this.

----------


## macropod

Having now seen your document, the problem you're having with it is that it has _InlineShape_ objects, not _Shape_ objects, in the even page headers & footers. You don't see them because the page layout doesn't have the 'different odd and even' option checked. The macro was only written to deal with Shape objects because they're the only ones that can be moved outside the visible area of the page. Either kind of object can be stored in a header or footer and remain unseen if that header/footer isn't displayed.

You could wipe the lot out with code like:



```
Please Login or Register  to view this content.
```

----------


## gl2excel

Even though it remove every image in the footer and header, without distinguishing if they are visible or not, now the script it's working.

----------

