Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2012, 12:24 PM
sleake sleake is offline Need a macro to convert all graphics to GIF format Windows XP Need a macro to convert all graphics to GIF format Office 2007
Advanced Beginner
Need a macro to convert all graphics to GIF format
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 02-09-2012, 04:20 PM
macropod's Avatar
macropod macropod is offline Need a macro to convert all graphics to GIF format Windows 7 64bit Need a macro to convert all graphics to GIF format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 02-10-2012, 08:59 AM
sleake sleake is offline Need a macro to convert all graphics to GIF format Windows XP Need a macro to convert all graphics to GIF format Office 2007
Advanced Beginner
Need a macro to convert all graphics to GIF format
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 02-10-2012, 05:00 PM
macropod's Avatar
macropod macropod is offline Need a macro to convert all graphics to GIF format Windows 7 64bit Need a macro to convert all graphics to GIF format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Sleake,

With the code I posted before, simply change '13' to 'wdPasteEnhancedMetafile' (or '9').
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
macro, macro find graphics, paste special

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a macro to convert all graphics to GIF format Macro to convert text to endnote? Orifacious Word VBA 27 03-29-2022 02:58 PM
Need a macro to convert all graphics to GIF format Macro to convert word file into pdf cc9083 Word VBA 2 02-23-2015 01:22 AM
Need a macro to convert all graphics to GIF format Creating macro to convert/print to pdf shabbaranks Word 3 05-18-2011 08:59 AM
Need a macro to convert all graphics to GIF format 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft