PDA

View Full Version : VBA to open Excel & Enable Macro



countryfan_n
08-11-2009, 01:08 PM
Hello Friends,

I need your help, I have an excel sheet named "trk".

Here is what I kindly need from you:

1. The comupter (Windows), to open the excel sheet on 6 AM everyday except for Thursdays & Fridays.
2. When the excel sheet opens, it enables the macro.
3. The excel sheet is located in the following directory
C:\MyDocuments\Temp\trk.xls

Thanks & Best Regards,
Nawaf

macropod
08-11-2009, 04:01 PM
Hi Nawaf,

Thankfully, vba can't be used to enable macros in a file - virus writers would just love it!

Bob Phillips
08-11-2009, 04:26 PM
I think he means just run the macro.

Nawaf, will the computer always be on, can the workbook be left open at all times, just firing the macro as required?

macropod
08-11-2009, 10:14 PM
Hi xld,

On my reading, Nawaf wants to open a work book at 6 AM everyday except for Thursdays & Fridays and automatically run a macro in it, without having someone tell Excel to enable macros. Unless macro protection is turned off or, in Office 2007, the workbook is stored in a tructed location, that can't be done. Nawaf asks for something that 'enables the macro', which I take as an indication that neither of the foregoing applies.

The only way around this that I'm aware of would be to have the macro code stored in the user's Personal.xls file and run it from there.

mikerickson
08-11-2009, 10:31 PM
If I recall correctly, if you set a workbook to run a macro OnTime, and close the workbook, the book will open and the macro will run at that time. I don't think that you can quit Excel though.