tags:

views:

442

answers:

4

hello i keep getting an error when calling a function via the OnTime method i tryed what's written here (and even posted a comment in the end) and i keep getting an error: "The macro 'I:\myFolder\test.xls'!MacroName was not found". when calling the function MacroName from anywhere in the script, it works fine.

thanks in advance for any help

A: 

Did you check your "macro level security" as suggested by this Microsoft technote ?

On the Tools menu, point to Macro, and then click Security. On the Security Level tab, change your setting to either Medium or Low.

NOTE: The setting that you will want varies according to your circumstances. The default in Excel is Medium.


Now, when it comes to the code of MacroName, you can only put the event procedure in the ThisWorkbook module (i.e Macro_Name).

The other procedures must go in a normal module.

VonC
A: 

Does the path shown in the error message match the location of the workbook that contains the macro?

It could be something else, but any time a path is displayed I get suspicious that I've loaded something from a different location and Excel is still (correctly, since it doesn't know you moved the file) looking for the macro in the original location.

Mike Woodhouse
A: 

Yes, the path matches. this is my first ever macro, so i recodnize it :)
Oddly enough, now it works, but only when MacroName is placed in a new Module.

How can that be explained?

I just completed my answer: only the event procedure should be kept in 'ThisWorkbook'
VonC
+1  A: 

I'm pretty sure your problem is that the code is not in a standard module, and instead in the ThisWorkbook module...I'm not sure why but the code needs to be in a standard module to work, though you may want to try changing the OnTime method call to "ThisWorkbook.Subname"

Jon Fournier