Sub RemoveBackground()
Dim selectedPicture As Picture
Set selectedPicture = ActiveSheet.Pictures("Picture 3")
' Set the transparent color of the picture
With selectedPicture.ShapeRange.PictureFormat
.TransparentBackground = True
.TransparencyColor = RGB(255, 255, 255)
End With
End Sub
Sub RemoveShapes()
' Select the image you want to remove the background from
Dim selectedImage As Shape
Set selectedImage = ActiveSheet.Shapes("Image1") ' Set the transparent color of the image
With selectedImage.PictureFormat
.TransparentBackground = msoTrue
.TransparencyColor = RGB(255, 255, 255)
End With
End Sub
2条答案
按热度按时间qojgxg4l1#
这需要几个步骤:
1.在工作表上放置自选图形(如矩形)
1.使用以下命令将实际图片嵌入到矩形中:
.ShapeRange.Fill.UserPicture
1.使用以下命令调整透明度:
.ShapeRange.Fill.Transparency
aurhwmvo2#
可以使用以下代码:删除背景图像并使用工具图片格式,在Excel中设置透明颜色。