gpt4 book ai didi

excel - 如何控制图像透明度?

转载 作者:行者123 更新时间:2023-12-04 21:22:32 24 4
gpt4 key购买 nike

我的工作表中有一张我想淡出的图像。
我想为图像设置不同的透明度阶段:

Set myPicture = ActiveSheet.Pictures.Insert(pic)

With myPicture
.Transparency = 0.5
Application.Wait (Now + TimeValue("00:00:01"))
.Transparency = 0.3
Application.Wait (Now + TimeValue("00:00:01"))
.Transparency = 0.1
Application.Wait (Now + TimeValue("00:00:01"))
.Delete
End With
我收到一条错误消息。

object not supported

最佳答案

我花了很长时间才让它工作(直到我尝试了 DoEvents )

Sub FadeInFadeOut()
Dim r As Range
Set r = Selection
ActiveSheet.Shapes("Rectangle 1").Select
Selection.ShapeRange.Fill.Transparency = 1

For i = 1 To 100
Selection.ShapeRange.Fill.Transparency = 1 - i / 100
DoEvents
Next

For i = 1 To 100
Selection.ShapeRange.Fill.Transparency = i / 100
DoEvents
Next

r.Select
End Sub

它适用于我放置在图纸上的自选图形。

注意:

您必须调整 100 调整淡入/淡出速度。

编辑#1:

这是一些垃圾代码(基于记录器),用于将自选图形放在一张纸上并用图片填充它:
Sub PicturePlacer()
Dim sh As Shape

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 312.75, 176.25, 266.25, 129.75). _
Select

Selection.Name = "Sargon"

Application.CommandBars("AutoShapes").Visible = False
Range("G4").Select
ActiveCell.FormulaR1C1 = "123"
Range("G5").Select
ActiveSheet.Shapes("Sargon").Select
Selection.ShapeRange.Fill.Transparency = 0.56
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.UserPicture "C:\Users\garys\Pictures\babies.jpeg"
End Sub

请记住命名形状并在引用该形状的所有代码中使用该名称。

关于excel - 如何控制图像透明度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41223436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com