Current location - Health Preservation Learning Network - Slimming men and women - Right-click to block all charts and pictures in vba.
Right-click to block all charts and pictures in vba.
Sub? xx()

This code filters all right-click menus the first time it runs, and restores the settings the second time it runs.

Dim? Me? As? Dragon? My bar? As? Command bar

For what? Every one? My bar? Are you online? Apply. The Command Bar cycles through all command bar menus.

What if? Mine. Type? =? msoBarTypePopup? If the menu is a pop-up menu.

Me? =? Me? +? 1

ActiveSheet。 Cells (me,? "a") =? Mine. name

ActiveSheet。 Cells (me,? “B”)? =? Mine. name

Mine. Enable? =? Isn't it? Mine. enable

ActiveSheet。 Cells (me,? “C”)? =? Mine. enable

Note that after the code runs, you must press Enter to distinguish which menus you need.

End? if

then

End? Sub, check for yourself which menus need to be blocked!

For a chart, it should contain more than one right-click menu, and we must distinguish these menus one by one in order to be targeted.

Or you can provide the attachment, and I will help you analyze it!

I made a class module test attachment for you. You can download the attachment for testing. At present, it seems to be blocked for picture objects.

The shape toolbar can prevent the right-click menu from popping up.

The chart is too complicated, you can download the attachment to test it:

I wish you a happy Mid-Autumn Festival! ! (Blessing from Bashu Brothers unsamesky)