Opening an Excel sheet which contains macros
Visual basic 6.0
During opening an excel sheet which contains macros a pop-up window ask you to select to enable or disable macros.
In a visual basic program which opens such file to read or write data, how can I make the program to select automatically from the pop up window to enable or disable macros or to close the pop up window in order to complete data reading or wtiting?
Re: Opening an Excel sheet which contains macros
from within excel, you can stop the dialog from displaying, by either lowering the security level so that macros are always permitted, or you can digitally sign your macros and add that signature to the trusted signatures.
if you don't have permissions to do that, probably you should not try to disable the warning
pete
Re: Opening an Excel sheet which contains macros
You never want to lower your security settings to low. You could set Displayalerts off but then you will get the default button choice,
which in this case is, Disabled.
Like westconnt mentioned you could digitally sign your code but it would only be for personal use. If you need to distribut your app then a profesional
public certificate is needed. You dont want anyone to take your private DS and use it without your approval. ;)
Check out my CodeBank tutorial on Creating a Trusted Digital Signature.
Re: Opening an Excel sheet which contains macros
i can close the macro warning box easy enough, using sendkeys, but it leads to other problems, that are undesirable.
you would need to use apis to make it work reliably
pete
Re: Opening an Excel sheet which contains macros
I doubt that the macros dialog box window is manipulatable via APIs like SendMessage and PostMessage as this would completely
defeat the medium level of macro security. It would allow code to automatically enable a macro and run it without the users approval.
SendKeys is probably the only option although not a good one.