• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2075
  • Last Modified:

VBA Script to Convert all Images from eps to jpg or png

Hi,

My company has a few hundred word documents with eps images in them. Recently we became aware that these documents do not work correctly in Word 2008 for mac, because of an updated EPS filter or similar causing the images to be displayed improperly. I am looking for a VBA Script to read the document and convert the EPS files to a different format like JPG, PNG, or even WMF I guess, so that Word 2008 on mac can use these documents.

I am open to using other languages to perform this task as well, I just figured that VBA would be better suited to it as it is built into the office suite.

The documents were created in Word 2003
0
jrm213jrm213
Asked:
jrm213jrm213
1 Solution
 
jrm213jrm213Author Commented:
Ok, well I was able to write a script to accomplish this in an acceptable manner so that Word 2008 for Mac can now properly open and print these files. I just have to run this script on each document.

You probably don't need the IconLabel or the i variable, I was just using them to count how many items I replaced to make sure it got all the images.
Dim oIshp As InlineShape
  Dim oshp As Shape
  Dim i As Integer
  
  i = 0
    For Each oshp In ActiveDocument.Shapes     
        With oshp
            If (oshp.Type = 11) Then
            i = i + 1
                oshp.Select
                ActiveWindow.Selection.CopyAsPicture
                ActiveWindow.Selection.Range.PasteSpecial datatype:=wdPasteEnhancedMetafile, IconLabel:="moved" + Str(i)
                ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Top = oshp.Top
                ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Left = oshp.Left
                oshp.Delete
            End If
            
           
        End With
    Next oshp

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now