Graviton
Graviton

Reputation: 83284

Export pictures in Microsoft Word to TIFF

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.

Upvotes: 1

Views: 3529

Answers (2)

Graviton
Graviton

Reputation: 83284

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 :)

Upvotes: 2

Vaibhav
Vaibhav

Reputation: 11436

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.

Upvotes: 0

Related Questions