Getting images out of a microsoft word file

Getting images out of a microsoft word file

I once had a client who scanned in hundreds of old photographs directly into Microsoft Word file only to need them in their raw formats for use in another application.

Needless to say it wasn’t favourable to redo the hours of scanning to save them as JPEGs or similar and hence I was called in to see if there wasn’t an easier way to do things.

Whilst there are old scripts knocking around, they weren’t foolproof as they split out the images in BMP format and often corrupted the images and left damaged pixels for one or other reason.  With a bit of hacking and help from the chaps below I was able to run the below as a macro and save the day!

I hope it helps someone in a similar situation.  It was a while ago and I cannot remember if I am giving all credit where it is due so apologies if I have missed someone out.

As far as I can remember this would work with most variants of Office files such as Excel and Powerpoint too.

Below is a script of VBA code which can be used as a macro to loop through a directory of files with an optional mask, opening and saving and then closing the documents.

By saving as html files the images are split out in a more coherent manner than if they were saved out as bitmaps via another VBA script which has left a cross of damaged pixels on the centre of the image and from top-bottom & left-right.

The FilePathSearch2007 function is credited to a chap in the forums called Phil_V http://www.excelforum.com/excel-programming/690124-application-filesearch-excel-2007-update.html and is used as a workaround to the “With Application.filesearch” method which worked on version prior to Office 2007.

Leave a Reply

Your email address will not be published. Required fields are marked *