How do I enable a macro using vba?

davin2929

Board Regular
Joined
Oct 13, 2002
Messages
129
When I open the workbook with an Auto Run macro in it the first thing that pops up is the disable/enable macro alert. I would like to set the code in the Auto run macro to disable that alert so when I open the workbook the Macro runs without clicking disable or enable macros.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Mark O'Brien

MrExcel MVP
Joined
Feb 15, 2002
Messages
3,530
You can't.

Thinking about it logically, how can you set a macro up to enable macros? For the macro to work, macros would have to be enabled.

This is a security feature to protect people from malicious code.

This question has been discussed several times on this board before. The general consensus is that lowering your security to always enable macros is a bad idea. A slightly better idea is digital signatures, Corticus has a decent description here of how to use these:

http://216.92.17.166/board/viewtopic.php?topic=21566&forum=2

HTH
 

skadan

Board Regular
Joined
Sep 5, 2002
Messages
54
I wondered about this too :)

Mark is correct though, it can't be done. However, if you have MS Office, install the vba self-cert 'add in' from MS tools option.

You can then create a digital certificate, which when attached to your vba code (in vb editor) will allow your project to bypass security/macro dialogue each time.

Lookup "certificates" in xl & vba help for more info
 

Mark O'Brien

MrExcel MVP
Joined
Feb 15, 2002
Messages
3,530
On 2002-10-16 16:46, skadan wrote:
I wondered about this too :)

Mark is correct though, it can't be done. However, if you have MS Office, install the vba self-cert 'add in' from MS tools option.

You can then create a digital certificate, which when attached to your vba code (in vb editor) will allow your project to bypass security/macro dialogue each time.

Lookup "certificates" in xl & vba help for more info

..or just follow that link I posted and follow corticus' procedure.
 

Forum statistics

Threads
1,148,013
Messages
5,744,343
Members
423,863
Latest member
teehexcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top