+ Reply to Thread
Results 1 to 22 of 22

Remove unneeded images from a Word 2007 document

  1. #1
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Remove unneeded images from a Word 2007 document

    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.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    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.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

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

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

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

  5. #5
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    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.

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by gl2excel View Post
    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.

  7. #7
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by macropod View Post
    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.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by gl2excel View Post
    Because images are nowhere in the document and they are not outside the page boundaries.
    And how did you establish that?

  9. #9
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by macropod View Post
    And how did you establish that?
    Because I can't see the images in the few pages of the document.

  10. #10
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

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

  11. #11
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by macropod View Post
    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 ?

  12. #12
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    You could delete all shapes with a macro like:
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    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.

  14. #14
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by gl2excel View Post
    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.

  15. #15
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    Quote Originally Posted by macropod View Post
    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.

  16. #16
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    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.
    Last edited by macropod; 12-13-2015 at 08:04 AM.

  17. #17
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    '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.

  18. #18
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

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

    Code in previous post updated.

  19. #19
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    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.

  20. #20
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    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.

  21. #21
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Remove unneeded images from a Word 2007 document

    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.
    Last edited by macropod; 12-13-2015 at 07:20 PM.

  22. #22
    Registered User
    Join Date
    12-13-2014
    Location
    Somewhere
    MS-Off Ver
    Office 2007 Sp3
    Posts
    20

    Re: Remove unneeded images from a Word 2007 document

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 05-29-2015, 02:25 AM
  2. Resize images in word document using excel vba
    By nsr2105 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2014, 01:36 AM
  3. Replies: 2
    Last Post: 08-08-2013, 02:22 PM
  4. [SOLVED] Remove a specific word line from a word document.
    By Will_2013 in forum Word Formatting & General
    Replies: 4
    Last Post: 05-26-2013, 07:01 PM
  5. Can't extract images from Excel 2007 Document
    By jsteve01 in forum Excel General
    Replies: 10
    Last Post: 05-23-2013, 12:27 AM
  6. Inserting multiple images from a unique URL to a word document via VBA
    By simon1985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2012, 04:19 AM
  7. Finding text within a Word document and Inserting Images
    By nickypatterson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2011, 04:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1