Opening a file and enabling macros automatically

F

Fernandoalberte

Guys,

When you open an excel file which has VB code in it, you are aske
(depening on your macro security settings) if you would like to disabl
or enable macros.

Is there a way (perhaps via the auto_open code to stop this messag
popping up and automatically enabling these macros?

Look forward to hearing your thoughts.

Regards,

Fernand
 
D

Dave Peterson

If macros are disabled, then auto_open won't run.

This is a security measure. If you could bypass this level of security, then it
wouldn't be very useful.


One way around it is to use a dummy workbook that contains one worksheet and a
macro that opens the real workbook (and closes the dummy workbook).

Have the user open that. If macros are disabled, the macro won't run and the
user can see your warning on that single sheet: "Please open with macros
enabled!"

If the user opens with macros enabled, then the real file opens with its macros
enabled.

The macro could look like this:

Option Explicit
Sub auto_open()
Workbooks.Open Filename:="c:\my documents\excel\book2.xls"
ThisWorkbook.Close savechanges:=False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top