• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to fill white color to Multiple pictures

navic

Active Member
On the worksheet I have several hundred pictures.
I want to select all the images at once and add white background color to multiple images (solid fill -> white color) at once using VBA.
Is there any usable VBA?
Please see attached example.
 

Attachments

  • examplefillcolor.xlsx
    40.5 KB · Views: 3
No need for VBA.

Just use "Editing" ribbon tool located at Home tab.

Click on Find & Select -> Selection Pane

CTRL and Click on desired objects.
61154

Then right click on one of the object in the sheet and Format Object. Choose your fill color.
61155

Fill -> Solid Fill & choose color. Done.
 
For VBA... assuming there are no other shapes in the sheet.

Code:
Sub Demo()
Dim shp As Shape

For Each shp In ActiveSheet.Shapes
    With shp.Fill
        .ForeColor.RGB = RGB(255, 255, 255)
        .Solid
    End With
Next
End Sub
 
Hi @Chihiro
Thanks for your advice, I still need VBA because I will call it from another VBA macros.
Also, thank you for VBA code.

Hi @vletm
That's what I need. Thanks

In the meantime, I tried the option of selecting all images and recording a VBA macro (but I have over several hundred images).
I was not happy with these macros below.

Code:
Sub Macro1()
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Solid
    End With
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
End Sub
-----------------
Sub Macro2()
    ActiveSheet.Shapes.Range(Array("Picture 1")).Select
    ActiveSheet.Shapes.Range(Array("Picture 1", "Picture 3")).Select
    ActiveSheet.Shapes.Range(Array("Picture 1", "Picture 3", "Picture 4")). _
        Select
    ActiveSheet.Shapes.Range(Array("Picture 1", "Picture 3", "Picture 4", _
        "Picture 5")).Select
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Solid
    End With
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
End Sub

Respect for both

Problem SOLVED
 
Back
Top