2017-06-02 123 views
0

我正在写一个宏观上的图片(的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 Sub 

Public 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 

然而,尽管打开屏幕更新关闭,这仍然导致屏幕刷新/ FLI克尔。任何想法如何我可以防止这一点?

回答

0

阅读某处Visible = True/False可能会触发重新计算工作表,这可能会导致闪烁。在您的代码中,值得尝试将计算设置为手动。

+0

谢谢,但不起作用 – Absinthe