PC Review


Reply
Thread Tools Rate Thread

Automatically enable the macros when a excel file is opened

 
 
=?Utf-8?B?U2Fua2Fy?=
Guest
Posts: n/a
 
      17th Nov 2006
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 With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      17th Nov 2006
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" <(E-Mail Removed)> wrote in message
news:E4BB83D6-E9F0-4885-88FF-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?U2Fua2Fy?=
Guest
Posts: n/a
 
      17th Nov 2006
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" <(E-Mail Removed)> wrote in message
> news:E4BB83D6-E9F0-4885-88FF-(E-Mail Removed)...
> > 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 With Quote
 
NickHK
Guest
Posts: n/a
 
      17th Nov 2006
You will not able to... because macros have been enabled yet.
If you can't sign it and macro security is not set to low, then you will be
able to open and run code in your workbook.
That's why there is security; to prevent unwanted code from running.
And as far as Excel see it, your code is not authourised by the user.

NickHK

"Sankar" <(E-Mail Removed)> wrote in message
news3C8C3F0-4CDC-428C-8BA6-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:E4BB83D6-E9F0-4885-88FF-(E-Mail Removed)...
> > > 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 With Quote
 
John Coleman
Guest
Posts: n/a
 
      17th Nov 2006
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" <(E-Mail Removed)> wrote in message
> > news:E4BB83D6-E9F0-4885-88FF-(E-Mail Removed)...
> > > 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 With Quote
 
=?Utf-8?B?U2Fua2Fy?=
Guest
Posts: n/a
 
      20th Nov 2006
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" <(E-Mail Removed)> wrote in message
> > > news:E4BB83D6-E9F0-4885-88FF-(E-Mail Removed)...
> > > > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically open Excel file set to "Enable Macros" =?Utf-8?B?TGlzYSBN?= Microsoft Excel Discussion 3 24th Aug 2006 02:07 AM
Can we require "Enable Macros" or else the file can't be opened? =?Utf-8?B?UGF0cmljaw==?= Microsoft Excel Programming 2 17th May 2006 02:00 AM
Enable macros automatically for a workbook =?Utf-8?B?RGlhbmUgQWxzaW5n?= Microsoft Excel Misc 4 16th Feb 2005 05:48 PM
How to automatically enable macros? =?Utf-8?B?Q2hhcmxlcyBNb3JnYW4=?= Microsoft Word Document Management 4 4th Nov 2004 05:32 PM
automatically enable macros Lisa Microsoft Excel Setup 3 23rd Mar 2004 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:11 AM.