I still have to disagree about there being a security issue.
The Virus Warning is there to tell you a new workbook that you have received has got macros in it so could easily mess your computer/files up.
If you do not trust the source of this workbook you would not enable macros so would not risk infecting other files, etc.
If you create your own procedure there does not need to be this test, as you are not going to program a virus and run it on your own machine, nor are you going to programmatically open workbooks you don't trust.
Sorry DrBowes but I'm on Mike's side here. Macro virus security is not only there to help stop virii starting in the 1st place but also to stop them propagating and causing more widespread damage. '97 on NT certainly prompted when opening a workbook with macros via code and also DIDN'T run any auto_open macros unless prompted to do so
Rgds, Geoff [blue]Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?[/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
I see your point that once a virus gets started it can run amok, but it could still infect all the workbooks that don't already contain code, and add code to them too. In fact once a rebellious workbook is allowed to do what it wants pausing to ask about whether to enable macros in existing workbooks is going to do little to slow it down. More likely it would target other things like the registry or just delete files anyway.
I'm sure I had Excel 97 previously and opened workbooks programmatically without being asked to enable their macros, but I don't have access to it anymore so cannot be sure....
I have never seen virus protection as any more than a warning when I open new workbooks I have received, and for this it serves as a useful protection. If I am emailed a spreadsheet from an unknown source I would open with macros disabled first and check it over to make sure it won't do anything untoward. If the VBA code is protected I would not proceed unless I trusted the source.
How can this work: application.displayalerts ???
Your are asks to enable macros before any macros are run, so if you place "application.displayalerts" in a macro it is too late, no???
Hi Mike,
it seems that it is possible to disable macros only since xp version, with new AutomationSecurity property. There you can use:
Application.AutomationSecurity = msoAutomationSecurityForceDisable
(other options: msoAutomationSecurityByUI, msoAutomationSecurityLow - the default).
Hi again,
There is an indirect possibility to block auto macros in excel 2000 (and earlier version) while opening workbook by code. It can be done via EnableEvents property (acts on all workbooks). It is also possible to switch design mode if the "design mode" button is available in any visible or hidden toolbar (ID=1605 in excel 2000) The combination of both:
[tt]Dim x As Workbook
Dim cbc As CommandBarControl
' disable event macros
Application.EnableEvents = False
Set x = Workbooks.Open("Path & Filename"
x.Activate
Application.EnableEvents = True
' find & execute "Design mode" button
Set cbc = CommandBars.FindControl(Type:=msoControlButton, ID:=1605, Visible:=False)
cbc.Execute
Set cbc = Nothing[/tt]
In the way of related problems. When you hold down the shift key on a document or workbook when you open it, the macros should not run. Recently, I have found that this approach did not work and the macros ran in the workbook. This sounds like a related problem. It was on a network profile when I tested it and it was an Excel workbook.
Regards, RBVBA.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.