Copy-paste works, Cut-Paste doesn't

Add-in Express™ Support Service
That's what is more important than anything else

Copy-paste works, Cut-Paste doesn't
 
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello Abhijeet,

I'm sorry for the delayed response: we were on holidays this Monday-Tuesday.

I've reproduced the issue using the code and the file you sent me. I've also tried to comment out the use of the _CutCopyRange variable but this didn't help. Tomorrow, I'll check if this issue is reproducible using VBA.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 May, 2017 09:52:33 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello Abhijeet,

Unfortunately, the issue is also reproducible using VBA in Excel 2016 . Below are the macros used; they should be located within a worksheet class (such as Sheet1). Compile the macros and set them to work by running the startJob macro. Open the Immediate window (Ctrl+G) in the VBA IDE, switch to the "Not Working here" worksheet and perform the steps; find the debug output in the Immediate window.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader

Option Explicit

Dim WithEvents ExcelApp As Excel.Application
Dim WithEvents cbs As Office.CommandBars

Dim theCutCopyMode As Excel.XlCutCopyMode

Sub startJob()
    Set ExcelApp = Application
    Set cbs = ExcelApp.CommandBars
End Sub

Sub stopJob()
    Set ExcelApp = Nothing
    Set cbs = Nothing
End Sub

Private Sub cbs_OnUpdate()
    If (theCutCopyMode <> ExcelApp.CutCopyMode) Then
        theCutCopyMode = ExcelApp.CutCopyMode
        Dim str As String
        If (theCutCopyMode = xlCopy) Then str = "xlCopy"
        If (theCutCopyMode = xlCut) Then str = "xlCut"
        Debug.Print CStr(Now), "CommandBarsUpdate. CutCopyMode changed: " + str
    End If
End Sub

Private Sub ExcelApp_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Debug.Print CStr(Now), "SheetChange", Target.Address, Target.Value
End Sub

Private Sub ExcelApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Debug.Print CStr(Now), "SheetSelectionChange", Target.Address
End Sub
Posted 11 May, 2017 08:39:07 Top
Abhijeet S




Posts: 12
Joined: 2017-03-27
Okay. This means we can't do anything about it. Right?
Posted 11 May, 2017 08:45:33 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
You know the range that is being cut. To find the range pasted, you need to wait for the string "Paste" to appear at the top of the Undo stack; the range pasted is the range selected. Use the code I posted at https://www.add-in-express.com/forum/read.php?SHOWALL_1=1&FID=5&TID=13077#nav_start to find the state of the Undo and Redo stacks. In the topic you'll find that 37 mentioned in the code should be replaced with 129.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 May, 2017 09:22:03 Top
Abhijeet S




Posts: 12
Joined: 2017-03-27
Hello Andrei,

To find the range pasted, you need to wait for the string "Paste" to appear at the top of the Undo stack; the range pasted is the range selected.
>> Where do I wait, which function? You mean Sheet_Change? But Sheet_Change is never called when you Cut-Paste.

Could you please modify the sample project and show me how to handle Cut & Paste? I am lost in Cut-Paste logic!

Please help.
Posted 14 May, 2017 20:14:20 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Abhijeet S writes:
>> Where do I wait, which function? You mean Sheet_Change? But Sheet_Change is never called when you Cut-Paste.


Use the CommandBarsUpdate event of the Excel Events component (ADXExcelAppEvents).

Abhijeet S writes:
Could you please modify the sample project and show me how to handle Cut & Paste?


This support level is included in the Premium subscription only.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 15 May, 2017 04:21:02 Top