none
How to capture WorkSheet Drag-Drop event in Excel VSTO 2010 ? RRS feed

  • Question

  • Hi,

    According to our requirements, I want to disable WorkSheet Drag-Drop from one WorkBook to another Workbook. So my first question is this, How can I achieve this ? Is there any event for Excel VSTO ?

    My second question is, How we can capture WorkSheet delete event ?


     

    Monday, February 8, 2016 11:04 AM

Answers

  • Hi Ajit,

    Thanks for the detail information.

    If you want to prevnet the information in the spreadsheets leaked, I don't think disable the drag-drop will work.

    >> And I'm dragging it into another workbook then previous workbook gets closed. So in this scenario, this workaround wont work.

    Sorry for the confustion. The workaround is only work for the sheet deleting. It will not work for moving sheet from one workbook to another.

    And after investigation, the Excel already provide the sheet deleting event. You can refer to link below about more detail:
    Application.SheetBeforeDelete

    However, sheet deleting is dfferent with moving sheet. If you want Excel to support the drag-drop and sheet moving event, you can try to submit the feedback from link below:
    Excel UserVoice

    Hope it is helpful.

    Regards & Fei

     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 12, 2016 6:52 AM
    Moderator

All replies

  • Hi,

    There is no drag-drop event exposed by VSTO or Excel PIAs. Would you mind sharing the reason why you want to disable the Drag-Drop to help us to understand the real issue?

    >>My second question is, How we can capture WorkSheet delete event ?

    Also there is also no worksheet delete event in VSTO. However, as a workaround we can use SheetActivate to simulat. And here is an example for your reference:

    Dim sheetnums As Integer
    Private Sub Workbook_Open()
    sheetnums = Sheets.Count
    End Sub
    
    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    
    
    If sheetnums > Sheets.Count Then
        MsgBox "sheet deleted"
      
    End If
    
      sheetnums = Sheets.Count
    End Sub

    Hope it is helpful.

    Regards & Fei



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Walt.Li Tuesday, December 6, 2016 2:28 AM
    Tuesday, February 9, 2016 7:21 AM
    Moderator
  • Hi Fei,

    Thanks for your answer. 
    In our project, we are encrypting Excel files. So I want to disable drag-drop of excel sheet from encrypted Workbook to non-excrypted workbook.

    And for second question, I saw your code workaround. But If there is only one sheet in a workbook. And I'm dragging it into another workbook then previous workbook gets closed. So in this scenario, this workaround wont work.

    -Regards
    Ajit

    Tuesday, February 9, 2016 9:23 AM
  • Hi Ajit,

    Thanks for the detail information.

    If you want to prevnet the information in the spreadsheets leaked, I don't think disable the drag-drop will work.

    >> And I'm dragging it into another workbook then previous workbook gets closed. So in this scenario, this workaround wont work.

    Sorry for the confustion. The workaround is only work for the sheet deleting. It will not work for moving sheet from one workbook to another.

    And after investigation, the Excel already provide the sheet deleting event. You can refer to link below about more detail:
    Application.SheetBeforeDelete

    However, sheet deleting is dfferent with moving sheet. If you want Excel to support the drag-drop and sheet moving event, you can try to submit the feedback from link below:
    Excel UserVoice

    Hope it is helpful.

    Regards & Fei

     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 12, 2016 6:52 AM
    Moderator