tags:

views:

1303

answers:

2

How to export pictures in Microsoft Word to TIFF file using Visual Studio Tools for Office? I can obtain a reference to the pictures as InlineShape object collection, the hard part now is how to save them as TIFF images.

A: 

Well. not sure if this is helpful, but you if you are okay with jpegs, then one really cool technique for extracting images from Word 2007 file is as follows:

  1. Rename the .docx file to .zip.
  2. Under the (now) zip file, go to the following path: word/media.
  3. All the images in the document are found here as jpeg files.

Cheers.

Vaibhav
Thanks, but I need to do it from scripts.
Ngu Soon Hui
+1  A: 

OK guys, I got the problem solved. Here's the code snippet:

        private void SaveToImage(Word.InlineShape picShape, string filePath)
    {
        picShape.Select();
        theApp.Selection.CopyAsPicture();
        IDataObject data = Clipboard.GetDataObject();
        if (data.GetDataPresent(typeof(Bitmap)))
        {
            Bitmap image = (Bitmap)data.GetData(typeof(Bitmap));
            image.Save(filePath);
        }
    }

Hope it helps :)

Ngu Soon Hui