Alex Martial
New Member
Hello Colleagues!
I have a little problem with making a locked shape be draggable/moveable by a user.
What am I trying to achieve?
1. There is a task for a user in an Excel file where they need to drag-n-drop several shapes (the blue ones on the attached screenshot) to appropriate positions (the grey ones on the attached screenshot) and in the appropriate order.
2. The worksheet was protected andidiot-user-proofed.
3. I need to allow a user to drag-n-drop a shape on the protected worksheet but I need to restrict any visual formatting, text editing and/or accidental deleting of a shape.
4. If I lock a shape it cannot be moved/drag-n-dropped. If I lock a shape but allow Object Editing, it can be moved but it is not protected, i.e. it can also be changed/edited/deleted. If I do not lock a shape, it can be moved, but it also can be changed/edited/deleted.
5. I found that there is the following approach: add all such shapes into ChartArea of a blank ChartObject and apply:
to the ChartObject. This solves a problem only partially - this is a good way to block a visual formatting, however, you cannot move the shapes. Actually, you can move them, but they will be pushed back to their initial positions, once you drop a mouse button.
If you apply
, you can interact neither with ChartArea, nor with the linked shapes.
6. I tried another approach, locked all shapes, created a transparent blank label and wrote a listener for MouseDown/MouseUp events. However, I feel like I'm trying to invent a bicycle, and I'm not sure that it was the best idea/approach because it has become far more complicated than it should be, especially with the necessity to imitate a drag-n-drop event and describe the logic for a shape's movements following the mouse pointer.
Do someone know any alternative for what I'm trying to achieve?
Thanks in advance.
I have a little problem with making a locked shape be draggable/moveable by a user.
What am I trying to achieve?
1. There is a task for a user in an Excel file where they need to drag-n-drop several shapes (the blue ones on the attached screenshot) to appropriate positions (the grey ones on the attached screenshot) and in the appropriate order.
2. The worksheet was protected and
3. I need to allow a user to drag-n-drop a shape on the protected worksheet but I need to restrict any visual formatting, text editing and/or accidental deleting of a shape.
4. If I lock a shape it cannot be moved/drag-n-dropped. If I lock a shape but allow Object Editing, it can be moved but it is not protected, i.e. it can also be changed/edited/deleted. If I do not lock a shape, it can be moved, but it also can be changed/edited/deleted.
5. I found that there is the following approach: add all such shapes into ChartArea of a blank ChartObject and apply:
Code:
.ProtectFormatting = True
.ProtectSelection = False
If you apply
Code:
.ProtectSelection = True
6. I tried another approach, locked all shapes, created a transparent blank label and wrote a listener for MouseDown/MouseUp events. However, I feel like I'm trying to invent a bicycle, and I'm not sure that it was the best idea/approach because it has become far more complicated than it should be, especially with the necessity to imitate a drag-n-drop event and describe the logic for a shape's movements following the mouse pointer.
Do someone know any alternative for what I'm trying to achieve?
Thanks in advance.