Change sharpness and brightness of a selected picture

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Change sharpness and brightness of a selected picture

Post by Peter Kinross »

Would anyone know how to change the sharpness and brightness of a selected picture using Word vba?
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change sharpness and brightness of a selected picture

Post by HansV »

For example:

Code: Select all

Sub PictureTest()
    With ActiveDocument.InlineShapes(1)
        With .PictureFormat
            .Brightness = 0.6
            .Contrast = 0.4
        End With
        .Fill.PictureEffects.Insert(msoEffectSharpenSoften).EffectParameters(1).Value = 0.3
    End With
End Sub
Best wishes,
Hans

snb
4StarLounger
Posts: 588
Joined: 14 Nov 2012, 16:06

Re: Change sharpness and brightness of a selected picture

Post by snb »

When already selected:

Code: Select all

Sub M_snb()
  With Selection.ShapeRange.PictureFormat
    .Brightness = 0.5
    .Contrast = 0.5
    .Parent.Fill.PictureEffects.Insert(25).EffectParameters(1).Value = 0.5
  End With
End Sub

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Change sharpness and brightness of a selected picture

Post by Peter Kinross »

Oh dear, I completely missed your reply Hans - sorry. No idea how that happened.

Code: Select all

Sub PictureTest()
    With ActiveDocument.InlineShapes(1)
        With .PictureFormat
            .Brightness = 0.2
            .Contrast = 0
        End With
        .Fill.PictureEffects.Insert(msoEffectSharpenSoften).EffectParameters(1).Value = 0.75
    End With
End Sub
The above Sub changes Sharpness to 75% - great; Brightness to -60% - not great; Contrast to -100% - not great.

The first line of the Sub M_snb() produces the error "Invalid procedure call"
Avagr8day, regards, Peter

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Change sharpness and brightness of a selected picture

Post by Peter Kinross »

Played around and got it working. Why, oh why did I change your values. :sad:

Code: Select all

Sub FixPic()
Dim Num As Integer
Num = ActiveDocument.InlineShapes.Count
For x = 1 To Num
    With ActiveDocument.InlineShapes(x)
        With .PictureFormat
            .Brightness = 0.6
        End With
        .Fill.PictureEffects.Insert(msoEffectSharpenSoften).EffectParameters(1).Value = 0.75
    End With
Next    'x
End Sub
ThanksHansStamp.gif
You do not have the required permissions to view the files attached to this post.
Avagr8day, regards, Peter