Excel 2010 Background of Image transparent

klarowe

Active Member
Joined
Mar 28, 2011
Messages
389
We just upgraded to Excel 2010 from Excel 2003 and I have a code that worked on 03 but now doesn't entirely work on 2010. Basically in 03 it would remove the black background of the image, but on 2010 it does not. Here is the code I have:
Code:
Sub InsertArrow()
    On Error GoTo Error
    ActiveSheet.Pictures.Insert( _
        "S:\SERVICE\Repair Shop CDRs\CDR Templates\CDR Pictures\red arrow.bmp" _
        ).Select
        With Selection.ShapeRange
            .PictureFormat.TransparentBackground = msoTrue
            .ScaleHeight 0.6, msoFalse
            .ScaleWidth 0.32, msoFalse
            .ZOrder msoBringToFront
            .PictureFormat.IncrementBrightness 0.06
            .PictureFormat.IncrementContrast 0.18
            .Fill.Visible = msoFalse
        End With
    Exit Sub
Error: MsgBox "Red Arrow cannot be inserted.", vbOKOnly, "Error"
    Exit Sub
End Sub

I can do it manually by selecting the picture, then Picture Format - Colors - Set Transparency Color - then selecting the background color. But it does not record in the macro recorder so I can't even get an idea on it.
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Bump. I have every other code modified to work with Excel 2010 and this is the last one I need. Anyone have any ideas? I also tried recording while doing the remove background and it still didn't record anything.
 
Upvote 0
Well I have a feeling that would happen. As soon as I bumped this and began looking again I happened to find my answer. I just had to figure out the RGB for the white background.
Here is the final code for anyone that may need this in the future:
Rich (BB code):
Sub InsertArrow()
    On Error GoTo Error
    ActiveSheet.Pictures.Insert( _
        "\\TBISUSFS001\Share\SERVICE\Repair Shop CDRs\CDR Templates\CDR Pictures\Red Arrow.bmp").Select
        With Selection.ShapeRange
            .PictureFormat.TransparentBackground = msoTrue
            .PictureFormat.TransparencyColor = RGB(255, 255, 255)
            .Fill.Visible = msoFalse
            .ZOrder msoBringToFront
            .Rotation = 270
            .LockAspectRatio = msoFalse
            .Height = 60
            .Width = 20
        End With
    Exit Sub
Error: MsgBox "Red Arrow cannot be inserted.", vbOKOnly, "Error"
    Exit Sub
End Sub

If you are reading this and would still like to help me, I am still looking for an answer here: http://www.mrexcel.com/forum/showthread.php?t=606289
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top