#1
|
|||
|
|||
Need a macro to convert all graphics to GIF format
I am working on a document with numerous screenshots of software windows. The author obviously pasted these in without converting the graphic file format. The document is now too large for users to download.
I've recorded a simple macro to cut the graphic and then use Paste Special to reinsert it as a GIF file. What I would like to do is create a macro that would go through the entire document, find each graphic, convert each to GIF and then repaste the modified graphic. Can anyone help with the VBA to do this? Here's the "little" macro: Sub ConverttoGIF() ' ' ConverttoGIF Macro ' ' Selection.Cut Selection.PasteSpecial Link:=False, DataType:=13, Placement:=wdInLine, _ DisplayAsIcon:=False End Sub |
#2
|
||||
|
||||
Hi sleake,
Try: Code:
Sub ConvertToGIF() Application.ScreenUpdating = False Dim i As Long, Rng As Range With ActiveDocument For i = .InlineShapes.count To 1 Step -1 Set Rng = .InlineShapes(i).Range Rng.Cut Rng.PasteSpecial Link:=False, DataType:=13, Placement:=wdInLine, DisplayAsIcon:=False Next End With Set Rng = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Paul: Thank you! I've tested and it works perfectly in seconds on a large document. However, the screenshots lose quality in the conversion to GIF. I've tested all the graphics formats available in the Paste Special dialog, and windows metafile and enchanced metafile formats are the best quality.
Thinking that the "data type = 13" in the macro referred to the graphic format, I re-recorded two macros, one with metafile and the other with enhanced metafile. But the macro looks different from the first one I recorded. They also are exactly the same. I'm not sure how to modify the code you sent to insert one of the metafile formats. Can you suggest? The second macro is below. Sub ConvertToMeta2() ' ' ConvertToMeta2 Macro ' ' Selection.Cut Selection.PasteAndFormat (wdPasteDefault) End Sub |
#4
|
||||
|
||||
Hi Sleake,
With the code I posted before, simply change '13' to 'wdPasteEnhancedMetafile' (or '9').
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
macro, macro find graphics, paste special |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to convert text to endnote? | Orifacious | Word VBA | 27 | 03-29-2022 02:58 PM |
Macro to convert word file into pdf | cc9083 | Word VBA | 2 | 02-23-2015 01:22 AM |
Creating macro to convert/print to pdf | shabbaranks | Word | 3 | 05-18-2011 08:59 AM |
Excel convert format [h]:mm:ss to decimal | gchan2000 | Excel | 1 | 08-17-2010 01:36 PM |
Convert a file from HTML to WORD format weblayout view | gtselvam | Word | 0 | 12-02-2008 03:53 AM |