VBA, Sometimes Loads, Sometime Disabled - Why?

J

james.igoe

I'm Excel/Access/VBa developer, and I've noticed that coded workbooks
intially open with VBA enabled, but subsequent workbooks do not.
Sometimes they do. In other instances, closing a coded workbook, but
leaving Excel open, prevent the next coded workbook from loading VBA,
but if the application is closed and another coded workbook is opened,
it loads fine.

Why?

It is not my code, but also another developer's coded books that do
the same thing. Macro security is set to medium, and the workstations
are locked down becuase we are in a large corporate enviroment.
 
S

ShaneDevenshire

Hi,

I'm not sure I've ever experienced what you are describing. Are you using
2003 or 2007? When I open any Excel file in 2003 with Macro Security set to
Medium, I am prompted wheather to enable or not. I have never had an Excel
file open without asking whether the macros should be enabled. However, I
work in a different enviornment. Is it possible that you have predefined
"Trusted Locations"? You may also want to look at the Trusted Publisher
stuff. Even if Excel is set to Medium, if a file is opened from a trusted
location, I believe you will not be prompted to enable. And I believe it is
similar for the trusted publisher.


Here is a discussion of that first topic:

A trusted location is typically a folder on your hard disk or a network
share. Any file that you put in a trusted location can be opened without
being checked by the Trust Center security feature. This article explains why
trusted locations can be useful and how you create them. It also outlines
precautions that you should take before using a trusted location.

In this article

--------------------------------------------------------------------------------

When should I use a trusted location?

Which trusted locations are safer?

Create a trusted location

Remove a trusted location

Change a trusted location


--------------------------------------------------------------------------------

When should I use a trusted location?
You should use a trusted location to store a file when you don't want that
file to be checked by the Trust Center security feature when you open the
file. For example, you might want to open a document that contains a macro
that the Trust Center disables because the Trust Center considers the macro
unsafe. If you think that the document and the macro in the document are from
a trustworthy source, it is better to move the document to a trusted
location, instead of changing the default Trust Center settings to a less
safe macro security setting. When you open the file from the trusted
location, it is not checked by the Trust Center security feature, you won't
receive any security alerts, and the macro is enabled. For more information
about macro security, see Enable or disable macros in Office documents.

Predefined trusted locations
If you work in an organization, your administrator might have created
trusted locations for you. Contact your administrator for more information
about using those trusted locations.

Default trusted locations
Several trusted locations are automatically created when you install the
2007 Microsoft Office system. The following are some examples:

drive\Program Files\Microsoft Office\Templates
drive\Program Files\Microsoft Office\Office12\Startup

Top of Page

Which trusted locations are safer?
A trusted location can be a folder on your hard disk or on a network share.
It is safer to use a local folder, such as a subfolder within the Documents
folder in Microsoft Windows Vista, or the My Documents folder in Microsoft
Windows XP, as long as you use a Microsoft Windows logon password to protect
your computer. Your password should be a strong password. For tips on
creating strong passwords and how to remember and store passwords securely,
see Creating stronger passwords.

Any locations that are not on your computer, such as a network share, are
less safe. You should not designate a public folder on a network share as a
trusted location for your files.

Important We recommend that you don't designate your entire Documents or My
Documents folder as a trusted location. Doing so creates a target for a
hacker to potentially exploit and increases your security risk. Create a
subfolder within Documents or My Documents and make only that folder a
trusted location.

Top of Page

Create a trusted location
Do the following in these 2007 Microsoft Office system programs:
Word, Excel, PowerPoint, or Access
Click the Microsoft Office Button , and then click Program Name Options,
where Program Name is the name of the program you are in, for example, Word
Options.
Click Trust Center, click Trust Center Settings, and then click Trusted
Locations.
Visio or Publisher
On the Tools menu, click Trust Center.
Click Trusted Locations.
If you want to create a trusted location that is not local to your computer,
select the Allow trusted locations on my network (not recommended) check box.
Click Add new location.
Important We recommended that you don't make your entire Documents or My
Documents folder a trusted location. Doing so creates a larger target for a
hacker to potentially exploit and increases your security risk. Create a
subfolder within Documents or My Documents, and make only that folder a
trusted location.

In the Path box, type the name of the folder that you want to use as a
trusted location, or click Browse to locate the folder.
If you want to include subfolders as trusted locations, select the
Subfolders of this location are also trusted check box.
In the Description box, type what you want to describe the purpose of the
trusted location.
Click OK.
Top of Page

Remove a trusted location
Do the following in these 2007 Microsoft Office system programs:
Word, Excel, PowerPoint, or Access
Click the Microsoft Office Button , and then click Program Name Options,
where Program Name is the name of the program you are in, for example, Word
Options.
Click Trust Center, click Trust Center Settings, and then click Trusted
Locations.
Visio or Publisher
On the Tools menu, click Trust Center.
Click Trusted Locations.
Under Path, click the trusted location that you want to remove.
Click Remove, and then click OK.
Top of Page

Change a trusted location
Do the following in these 2007 Microsoft Office system programs:
Word, Excel, PowerPoint, or Access
Click the Microsoft Office Button , and then click Program Name Options,
where Program Name is the name of the program you are in, for example, Word
Options.
Click Trust Center, click Trust Center Settings, and then click Trusted
Locations.
Visio or Publisher
On the Tools menu, click Trust Center.
Click Trusted Locations.
Under Path, click the trusted location that you want to change.
Click Modify, and then click OK.
In the Path box, type the name of the folder that you want to use as a
trusted location, or click Browse to locate the folder.
If you want to include subfolders as trusted locations, select the
Subfolders of this location are also trusted check box.
In the Description box, type what you want to describe the purpose of the
trusted location.
Click OK.
 
D

Dave Mills

I'm Excel/Access/VBa developer, and I've noticed that coded workbooks
intially open with VBA enabled, but subsequent workbooks do not.
Sometimes they do. In other instances, closing a coded workbook, but
leaving Excel open, prevent the next coded workbook from loading VBA,
but if the application is closed and another coded workbook is opened,
it loads fine.

Why?

It is not my code, but also another developer's coded books that do
the same thing. Macro security is set to medium, and the workstations
are locked down becuase we are in a large corporate enviroment.

One possible cause would be "sharing" the workbook. I am sure there are other
features that also turn off access to VBA but the only one I have used if
"shared workbook". Maybe "shared workbook" is being set up in code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top