Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Gurus,

I need to find out if user does, Right Click on a worksheet tab-->Opens Move or Copy dialog" and check the "create a copy "checkbox.

Please help me how to get the handle to move or Copy dialog controls in C# or VBA.

Thanks in Advance.

Vieer
Posted
Comments
Maciej Los 9-May-13 16:15pm    
Which version of MS Excel?
Virendra_ec10 10-May-13 1:20am    
Office 2007/2010

1 solution

No, it's not possible to handle "Move or Copy" dialog.

Please, refer these links:
Using Events with Microsoft Excel Objects [Excel 2003 VBA Language Reference][^]
Application Object Events [Excel 2003 VBA Language Reference][^]
Using Events with the Application Object (Office 2010)[^]

You can only handle new sheet event[^].

Steps to do:
1) Add new class module (change the Name property to: MyApp) and copy and paste below code:
VB
Public WithEvents ExcApp As Application

Private Sub ExcApp_WorkbookNewSheet(ByVal Wb As Workbook, ByVal Sh As Object)
    MsgBox "New sheet added!"
End Sub


2) Add new module and add insert line to it:
VB
Public oApp As MyApp


3) Go to the ThisWorkbook object (browse it in "Project - VBA Project" window on the left of code pane) and add this code:
VB
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set oApp = Nothing
End Sub

Private Sub Workbook_Open()
Set oApp = New MyApp
Set oApp.ExcApp = Application
End Sub


4) Set cursor position inside the body of Workbook_Open() procedure and push F5 key

5) Try to add new worksheet or use "Move or Copy" dialog with copy option ;)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900