Results 1 to 4 of 4

Excel 2010 Background of Image transparent

This is a discussion on Excel 2010 Background of Image transparent within the Excel Questions forums, part of the Question Forums category; We just upgraded to Excel 2010 from Excel 2003 and I have a code that worked on 03 but now ...

  1. #1
    Board Regular
    Join Date
    Mar 2011
    Posts
    374

    Default Excel 2010 Background of Image transparent

    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 by klarowe; Jan 11th, 2012 at 01:12 PM.

  2. #2
    Board Regular
    Join Date
    Mar 2011
    Posts
    374

    Default Re: Excel 2010 Background of Image transparent

    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.

  3. #3
    Board Regular
    Join Date
    Mar 2011
    Posts
    374

    Default Re: Excel 2010 Background of Image transparent

    another bump. Still having an issue and can't find an answer anywhere...

  4. #4
    Board Regular
    Join Date
    Mar 2011
    Posts
    374

    Default Re: Excel 2010 Background of Image transparent

    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:
    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: Automate Print Code to PDF?

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com