Andrew said:
I have 3 customised views and a customised toolbar (action buttons) for each
view. How would I program it so that when I opn up say view 2 I get toolbar
2, and with view 3 I get toolbat 3 etc..
each view is accessed via a simple macro :-
ViewApply Name:="02 - Programme Robustness View"
TableApply Name:="02 - Programme Robustness"
I am a novice at VBA and any help would be appreciated
Thanks in advance
Regards Andrew
Andrew,
Let me expand on Jan's response a bit. An Open Event macro can be
created using the command suggested in Jan's post to apply custom
toolbars to a particular Project file when it is first opened. The basic
code structure could be something like this:
Private Sub Project_Open(ByVal pj As MSProject.Project)
CommandBars(your custom toolbar name).Visible = True
[use a similar command to turn off unused toolbars, if desired]
End Sub
The above code should be placed in the VBAProject object. Do the
following:
1. Go to Tools/Macro/VisualBasicEditor.
2. When the editor opens, click the ProjectExplorer icon.
3. Then click on the VBAProject(xxx) object to open up the MIcrosoft
Project Objects folder.
4. Paste the above code in the blank code window to the right.
5. Go back and activate the Project file and do a "Save As" under the
same name to "capture" the new code.
6. Close the file. You can leave the VBEditor open or close it, it
doesn't matter.
7. Re-open the file, the Open Event code will "fire" and your custom
toolbar should appear.
However, you want to have different toolbars appear when different views
are selected and although that may be possible with more sophisticated
code, (the WindowViewChange Event comes to mind), it's probably not
worth the effort. I suggest you use the above structure to turn off
default but unused toolbars and apply both of your custom toolbars when
the Project is opened.
For reference, years ago I developed a series of custom macros for our
Cost Account Mangers (CAM) to use on their Project files. I created
multiple custom toolbars, (simple one button toolbars with descriptive
icons), and attached them to each of the CAM files. Whenever a CAM
opened their file the custom toolbars appeared, very much like what you
want.
By the way, if you're interested in learning more about Project VBA, I
suggest you take a look at fellow MVP, Rod Gill's book on the subject.
More information is available at,
http://www.projectvbabook.com
Hope this helps.
John
Project MVP