Excel VBA:更改按钮取消复制

时间:2013-12-01 18:19:39

标签: excel vba excel-vba

我的SelectionChange事件调用一个启用或禁用某些屏幕按钮的宏。

当然,当我想将某个东西从一个单元格复制到另一个单元格时,会触发SelectionChange。但是,启用和禁用按钮的命令(“。Enable = True”或“.Enable = False”)将取消正在进行的复制。 (单元格周围的动画边框消失了,好像我按下了Escape键,当我“粘贴”时没有任何反应。)

有解决方法吗?

- 肖恩

好的,这是:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim lboTemp As OLEObject
Dim ws As Worksheet
Dim Field As Range, FieldLabel As Range, Tbl As Range
Dim r, ob


If Application.Intersect(Target, Me.Range("D:D")) Is Nothing Then
    ' Disable buttons
    With Me.btnZoom
        .Enabled = False  ' **This cause "marching ants" to stop
        .Visible = True
        .Top = [Attr1].Top
        .Caption = "Zoom"
    End With

    With Me.btnAddToList
        .Enabled = False  ' **So does this (if I bypass the previous one)
        .Visible = True
        .Top = Me.btnZoom.Top + Me.btnZoom.Height + 5
        .Caption = "Add to List"
    End With
Else
   ' Enable buttons
    Call MoveZoomButtons  '**This macro enables the buttons, and likewise cancels the Copy
End If
         'More code
End Sub

0 个答案:

没有答案