Question

hi can you show a vb code for excel-2007 format->recolor->set transparent color on an a image inserted...

by the way, forgot to mention that excel-2007 record macro does not record this stuff otherwise i would not ask it here... :)

Was it helpful?

Solution

OK, here is a Macro that I wrote in Excel 2007 that works:

Sub Macro3()
    Dim NewSheet As Worksheet, oldws As Worksheet
    Set oldws = ActiveWorkbook.ActiveSheet

    Dim i As Integer, obj As Shape
    Dim picFmt As PictureFormat

    Set NewSheet = Worksheets.Add
    NewSheet.Range("A1").Value = oldws.Name
    i = 3
    NewSheet.Range("A2").Value = "Name"
    NewSheet.Range("B2").Value = "Link Type"
    For Each obj In oldws.Shapes
        NewSheet.Cells(i, 1).Value = obj.Name
        NewSheet.Cells(i, 2) = obj.Type
        Set picFmt = obj.PictureFormat
        With picFmt
            NewSheet.Cells(i, 3) = .TransparencyColor
            'set Black as the Transparent color'
            .TransparencyColor = RGB(0, 0, 0)
        End With
        i = i + 1
    Next
End Sub

OTHER TIPS

I recorded a macro in Excel 2003, and this is what I got:

Selection.ShapeRange.PictureFormat.TransparentBackground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyColor = RGB(5, 95, 209)
Selection.ShapeRange.Fill.Visible = msoFalse

I think this will work in Excel 2007 also, since everything tends to be forwards-compatible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top