COM Add-in replaces VBA

D

Doojoo

In project 2003 I have created some extra functions using VBA command
buttons. In project 2007 command buttons can no longer start VBA macros so I
created a COM Add-in containing the command buttons and the starting of the
VBA macro's.
Now I want to make sure my commandbar is only shown when my Project file is
has the focus (determined using a CustomDocumentProperty).
How do I do that?
 
S

Scudder

You'll need to trap the ProjectNew and Activate events and check the
project.CustomDocumentProperties for your property.

All commandbars and buttons have an ID, you can use this to make them
visible and enabled or invisible and disabled. You should set the ID when you
create these in your addin.

The project.CustomDocumentProperties is a collection and therefore squawks a
run time error if you attempt to retrieve the value of a non existing
property by name. This error can be trapped with an On Error Goto statement.

For example if your CustomDocumentProperty is called "MyCDProp", then the
following code will either retrieve the value or raise a run time error:

MYCDPropValue=myproject.CustomDocumentProperties("MyCDProp")

If it raises an error - it's not one of your projects, therefore switch the
buttons / command bars off using the ID as a reference.

If it doesn't raise an error - switch them on.

You'll need both events to call the same checkcode as you open various
projects and switch between them.

Lee.
 

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