MS Word Tip: Remove Pics from Document

Discussion in 'Scripting & Programming' started by Fergal1982, Apr 18, 2008.

  1. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    One of the girls at work had an issue where they needed to remove all pics from a word doc (it was about 2MB with the pics in, and needed to be drastically reduced for storage in the system).

    In case you ever need to do this, you can add the code below to a macro. Run it, and it will remove all pictures so that when you save it, the size of the document will be reduced.

    This is confirmed to work in both 2003 and 2007. I can post step-by-step instructions on how to do this in both if anyone wants.

    Code:
    Dim objPic As InlineShape
    Dim PicCount As Integer
    
    For Each objPic In ActiveDocument.InlineShapes
            objPic.Delete
            PicCount = PicCount + 1
    Next objPic
    MsgBox (PicCount & " Images Deleted")
    
    I also mapped this to a keyboard shortcut (Alt + `) so that its easier to run. If you are doing this sort of thing a lot, I would recommend it, otherwise you have to get into the macro menu and run it from there.
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  2. Tinus1959

    Tinus1959 Gigabyte Poster

    1,539
    42
    106
    2 MB isn't that big. You mean 2 GB perhaps?
     
    Certifications: See my signature
    WIP: MCSD, MCAD, CCNA, CCNP
  3. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    no it was 2MB. Not particularly big in terms of size, but for the app is was being loaded into, it was far too big, and crashing the app continually. Its a webapp, and doesnt like more than about 500K.
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  4. Bluerinse
    Honorary Member

    Bluerinse Exabyte Poster

    8,878
    181
    256
    Jeez Tinus a 2GB word doc.. what are you on, space cake? :p
     
    Certifications: C&G Electronics - MCSA (W2K) MCSE (W2K)
  5. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    oh, I wish he was. I've seen 2GB word files before.
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  6. Bluerinse
    Honorary Member

    Bluerinse Exabyte Poster

    8,878
    181
    256
    In which case the author needs to be shot :lolbang
     
    Certifications: C&G Electronics - MCSA (W2K) MCSE (W2K)
  7. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    oh yeah. part of the problem was the inclusion of large images without any attempt (or understanding of the need) to reduce the size of them. Resulting file was well over 2GB as I recall.
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  8. Tinus1959

    Tinus1959 Gigabyte Poster

    1,539
    42
    106
    Yep, me to. This guy even had some movies inside (avi).
     
    Certifications: See my signature
    WIP: MCSD, MCAD, CCNA, CCNP

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.