1

I have a 500+ page document with a lot of images. I need to convert all of these to grayscale and to increase sharpness by 40%. Both of these tasks can be done by right clicking each image and choosing 'format picture'. However because there are so many images I wish to use a macro. I am using word 2010.

I am able to convert all images to grayscale. However I am not able to sharpen them since I do not know the required command/keyword. The macro recorder does not record anything you do int the 'format picture' dialog box so it is of no help. Do any of you know the command?

Here is my working code so far that converts all images to grayscale.

Sub Macro1()

'
' Macro1 Macro
'
'

Dim Pic As InlineShape

For Each Pic In ActiveDocument.InlineShapes

    Pic.PictureFormat.ColorType = msoPictureGrayscale

Next

End Sub
2
  • 1
    In general if you use the toolbar buttons the actions will be recorded by the macro. So select a picture, start the recording then adjust the image.
    – Brian
    Aug 1 '11 at 22:19
  • Hi Brian. Thanks for your response. However in word 2010 the macro recorder appears to be quite useless. The only thing it records are cursor movements by the looks of it. So for example I start the recorder, move my cursor to the image using arrow keys, and then use the 'format' tool in the ribbon (which is available when an image is selected). I then click 'Corrections' and click 'sharpen 25%'. Unfortunately none of this gets recorded in the recorder. I have little previous experience with macro recorder but it only seems to record the most rudimentary of tasks. Does it work on your system?
    – Gary
    Aug 2 '11 at 6:34
3

Well, this was very hard to find any documentation but, trial and error and too much time and we have it.

Private Sub MakeItSharper()
Dim Pic As InlineShape    

For Each Pic In ActiveDocument.InlineShapes
With Pic.Fill.PictureEffects
    Dim eff As PictureEffect
    Set eff = .Insert(msoEffectSharpenSoften)
    eff.EffectParameters(1).Value = -0.5
End With
Next    

End Sub

In the above case, it will make it blurred by 50% (note it's a negative number (-0.5)). Make it positive to make it sharper.

4
  • I am aware the question was back in 2011 and I'm nearly 5 years late but... I wasn't on this site then :)
    – Dave
    Jun 17 '16 at 14:26
  • 1
    Perhaps, but you've answered a question that nobody else seemed to have an answer for. Thanks! Jun 17 '16 at 14:32
  • Dave, I had forgotten even asking this question, it has been so long :) Although I haven't tested your solution, I am going to assume it works, and will mark this as the right answer.
    – Gary
    Jun 20 '16 at 11:25
  • Yeah, I tested it :)
    – Dave
    Jun 20 '16 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.