Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automatically enable the macros when a excel file is opened

Thanks every one for the inputs. Current what I have done is create a self
certificate for the excel in the machine where it allows. Transfer the file
to where it should run and reinstall the self certificate there. The windows
task scheduler runs this excel(macro) currently it is running fine. I shall
try the VB script idea now.

Thanks Again.
regards,
Sankar
"John Coleman" wrote:

VBScript might be able to help you. Perhaps the entire functionality of
the macro can be transfered to a script which automates Excel and is
scheduled to run automatically. Alternatively - a script can sidestep
the security settings. For example, I created a workbook Test.xls with
this macro:

Sub Disabled()
MsgBox "I guess VBScript can run me"
End Sub

Then I wrote this script (in same directory - otherwise the file path
would need to be absolute of course):

'RunMacro.vbs

Dim xlApp, xlWB

Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.WorkBooks.Open("Test.xls")
xlApp.Run "Disabled"
xlWB.Close
xlApp.Quit
Set xlWB = Nothing
Set xlApp = Nothing

When this script is run - a message box with "I guess VBScript can run
me"
appears no matter what the security setting is. Some people might think
that this is a security hole. I think that it is by design and it makes
sense - if you have the authority to run a VBScript script then you
already have the authority to run code that is able to do just about
anything you want to - it is not like you are giving VBScript any
ability to do damage that it doesn't already possess. Allowing VBScript
to run macros in other applications seems needed if it is to be a
useful glue language.

Having said that, I'll hedge and say that I have not launched Excel
macros from scripts very often and there may be some limitations that I
am not aware of - but it gives you something to start with. Also, if
you were to schedule something like the above to run automatically, you
would probably want to put some error-trapping in (e.g.what if an
instance of Excel is already running).

HTH

-John Coleman


Sankar wrote:
Thanks Nick. Our environment does not allow the certificate to be created
even self :-). Probably I should try using some other commands to do enter
tab on the "Enable" Macros button.
Sankar


"NickHK" wrote:

You can sign your VBA code (maybe with a certificate made with Office's
SelfCert.exe) and your users would then have trust it.
After that your code can run without that dialog.

Otherwise, you cannot change a user's Security setting in code, thankfully.

NickHK

"Sankar" wrote in message
...
Hi,
I have an excel workbook with a macro. My requirement is to schedule to
run
the macro in this workbook. I am using a batch command to open the excel
book
and would be scheduled in the windows scheduled tasks.

When this excel sheet is opened it pops up the message to "disable" or
"enable" macros. Is there a way that I can automatically run the macro
without this message. I would not be able to change the security level of
macro to "Low" which is the commond option suggested by Microsoft and else
where.

Your inputs will be appreciated and greatly helpful.

Thanks,
Sankar





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run a macro automatically when the file is opened? LunaMoon Excel Discussion (Misc queries) 1 April 24th 10 01:01 AM
Enable Macros - Trust my file on my PC Bafa[_16_] Excel Programming 4 August 22nd 06 04:14 AM
Can we require "Enable Macros" or else the file can't be opened? Patrick Excel Programming 2 May 17th 06 02:00 AM
Enable macros automatically for a workbook Diane Alsing Excel Discussion (Misc queries) 4 February 16th 05 05:48 PM
Automatically enable macros for particular template Bryan Linton Excel Programming 1 February 2nd 05 10:31 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"