PDA

View Full Version : Solved: Macros to be disabled on the workbook



Sandeepn
07-30-2009, 02:20 PM
Hello All,

I have a code on access which runs a query and then opens a template excel workbook and runs the macros in it. I made the specified template excel file to run the macros upon opening it. The file retrieves info from various workbooks to prepare a report and saves it on the desktop with a date specified by me. I would send this report out to all

Problem:banghead:
The saved report upon opening still tries to run the macros as the template file. Is there a way to stop running the macros on the saved report? :think:

mdmackillop
07-30-2009, 03:53 PM
Welcome to VBAX
Test the name at the start of your sub.
eg

If Not (ActiveWorkbook.Name) = "Template.xlt" Then Exit Sub

Benzadeus
07-30-2009, 03:54 PM
I'm assumpting that each Access report need to run only once, right?

Why don't you make an addin and execute only once on your Access report file? This will also avoid the file being transmitted with the whole code inside it.

mdmackillop
07-30-2009, 03:57 PM
Why don't you make an addin and execute only once on your Access report file? This will also avoid the file being transmitted with the whole code inside it.
That's a much better solution!

Sandeepn
07-31-2009, 08:27 AM
Thanks Guys, i used the code what mac suggested, it works like magic, i will try the addin solution, but for now my problem is solved:thumb