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:
- Rename the .docx file to .zip.
- Under the (now) zip file, go to the following path: word/media.
- All the images in the document are found here as jpeg files.
Cheers.
Vaibhav
2008-10-04 06:53:32
Thanks, but I need to do it from scripts.
Ngu Soon Hui
2008-10-04 06:57:50
+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
2008-10-04 07:04:36