Domanda

I have been using a macro on an excel document that zooms in charts present in any sheet. The problem is, if I want to edit a chart, I must click it, triggering the zoom.

For this particular reason, I need to disable macros, and was wondering if there is either an easy to reach button or a keyboard shortcut to toggle it.

È stato utile?

Soluzione

In the XL file:

1) Press Alt+F11

2) Go to the ThisWorkbook module and comment out the two lines inside both subs.

3) Save and close the file, then reopen.

4) You can then edit to your hearts content.

5) To put the zoomer back on, uncomment the lines. You may need to Save, Close and Reopen again

NB -> see comments on original post for more information.

Altri suggerimenti

If you'd like a little more control without having to constantly comment/uncomment the macro, you might add something like this to the macro. Make sure you put it at the top, before any of the other code:

Dim mb As VbMsgBoxResult    'Declare a variable to hold the messagebox result
'Prompt the user:
mb = MsgBox("Would you like to edit this chart?", vbYesNo, "Edit Chart?")
If mb = vbYes Then
    Exit Sub   'If user wants to edit the chart, then exit this subroutine
    'a response of "No" will allow the sub to continue uninterrupted
End If

Without seeing exactly how the macro is being called, this might require some tweaking, but it's essentially just a prompt asking whether you want the macro (zoom) to continue, or whether you want it to terminate, allowing you to access the chart object for editing.

As of Excel 2010* there's actually an option on the "Developer" tab which allows you to disable macros as easy as ABC. Design Mode lets you do just that!

*Maybe even earlier versions.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top