当图片(ActiveX)被点击时,我正在编写一个宏以在图片顶部添加一个形状:
Private Sub clickpic_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
ClickShape CLng(x), CLng(y)
End SubPublic addedShapes() As Shape
Public sIndex As Integer
Sub ClickShape(x As Long, y As Long)
Dim shp As Shape
Application.ScreenUpdating = False
Set shp = ActiveSheet.Shapes.AddShape(msoShapeMathMultiply, x + ActiveSheet.Shapes("clickpic").Left - 10, _
y + ActiveSheet.Shapes("clickpic").Top - 10, 20, 20)
With shp.Fill
.ForeColor.RGB = RGB(255, 0, 0)
.backColor.RGB = RGB(255, 0, 0)
End With
shp.Line.Visible = False
shp.Name = CStr(shp.Top & shp.Left)
ReDim Preserve addedShapes(sIndex)
sIndex = sIndex + 1
Set addedShapes(UBound(addedShapes)) = shp
ActiveSheet.Shapes("clickpic").Visible = False
ActiveSheet.Shapes("clickpic").Visible = True
Application.ScreenUpdating = True
End Sub我发现the only way to display the shape immediately是启用和禁用图片的:
ActiveSheet.Shapes("clickpic").Visible = False
ActiveSheet.Shapes("clickpic").Visible = True然而,尽管关闭了屏幕更新,这仍然会导致屏幕刷新/闪烁。知道我怎么能阻止这件事吗?
发布于 2017-06-02 13:21:47
读取某个可见= True/False可能触发重新计算工作表的位置,这可能会导致闪烁。在您的代码中尝试将计算设置为手动是值得的。
https://stackoverflow.com/questions/44325795
复制相似问题