PDA

View Full Version : From main macro: Automatically Enable a macro when opening a file



jazzyt2u
09-15-2008, 04:53 PM
Hi,

I am using the following code to open unknown files in a folder and process them.
Sub OpenFiles()
Const FOLDER_NAME As String = "C:\test\" '<===== change to suit
Dim NextFile As String

NextFile = Dir(FOLDER_NAME & "*.xls", vbNormal)
Do While NextFile <> ""

Workbooks.Open FOLDER_NAME & NextFile
'do stuff on active workbook
NextFile = Dir
Loop
End Sub

The files will have macros. How do I automatically enable the macro so the user doesn't have to take the time to click the enable macro button?

Thanks

GTO
09-15-2008, 06:14 PM
Hi,

Have you tried the code? I only have access to 2003, but since the user had to enable macs to open the file containing the code, the files opened programatically should not fire the alert/warning. I tested your code nearly as written and opened several excel files (that do contain code) and received no warnings.

Mark