Worksheet_SelectionChange clears clipboard - can I stop this?
Hi all;
I have a Worksheet_SelectionChange event that sets the calculation mode.
When it runs the clipboard gets cleared, making it impossible to copy from
cell to cell. I tried using the DataObject to get the contents of the
clipboard and then restore them, but that generates a not-implemented error.
I have the required references etc. Is it possible to determine if cells
have been copied, and restore the clipboard with the same data at the end of
the Worksheet_SelectionChange event code?
Here's what I have now:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyDataObj As New DataObject
MyDataObj.GetFromClipboard
If Not (Intersect(Target.Cells(1, 1), Me.[LamTable]) Is Nothing) Then
Application.Calculation = xlCalculationManual
ElseIf [gCalc] = True Then
Application.Calculation = xlCalculationAutomatic
End If
MyDataObj.PutInClipboard 'ERROR here
End Sub
PS I have to do this because my Worksheet_Change event fails when a cell
with data validation is changed and the calculation mode is automatic. I
tried in vain to fix that, but it appears that the fact that my own
worksheet functions are affected makes it impossible. This hack works, but
the clipboard gets clobbered.
Thanks,
Stephen
__________________________________________________ __________________________
____
S. Fitzgerald, P.Eng, MASc.
Halifax, NS
Canada
|