Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run macro automatically

Status
Not open for further replies.

vidamj

IS-IT--Management
Apr 27, 2005
13
0
0
US
Currently I have a view that brings pieces of information together from the resource side and the task side into one view. I have a macro that enables this to happen but, it must be done manully using a CTRL-hotkey. I was wondering if there was a way to get this to run automatically when I open the view that i created so all the correct information shows up. Below was one suggestion but we have upgraded to using Project Server. Will this example still work? Any suggestions welcome. Thanks in advance.
1. Start Project
2. Alt+F11 to open VB
3. In the left panel, double-click on "ThisProject (GLOBAL.MPT)"

This will open a window on the right named "GLOBAL.MPT ThisProject(Code)"

At the top of that window, you'll see two dropdowns.

* One offers "(General)" or "Project" (You want "Project").
* The other offers a variety of envents. Choose your event.

4. Put the name of your macro there.

This assumes, of course, that your macro is in GLOBAL.MPT. If you've put your macro into a specific project and only want to access it in that project then on instruction 3, select "ThisProject(WhateverYourProjectIsNamed)" instead.
 
Also, the suggestion that was given (located above in this thread) I believe makes the change anytime something in the project plan is changed. This may become processor intensive depending on the size of the plan. Is there a way to get that to the view level. So when a view is opened my macro will run?
 
Since the Project object model doesn't expose the View Change event, your request is, obviously, impossible.

Your assumption "I believe makes the change anytime something in the project plan is changed" is somewhat incorrect. That would only happen if you hooked your code to the Change or Calculate events.

As for "we have upgrade to using Project Server. Will this example still work?" -- try it, report back on your findings.

Finally, you have the macro linked to a hotkey. Why not link it to a button on a tool bar so that clicking on the button does a ViewApply and then any other code you want executed?
 
I have linked the code to the change event and the macro to work when information in the project is changed. So it does work almost the same as project server. I think I had to use a different set of information for item 3 above.
 
Is there some function for a ViewApply? Also, there isn't code I can place someplace so that when my specific view is opened the other code I need to copy task column information to resource column information is run? I just want the information that has been typed into certain fields to update when that view is opened.
 
The VBA command is:

ViewApply Name:="Resource Sheet"

There is no event (or, at least, no exposed event) that you can add your code to. In other words, as I suggested above,

Create a button
Create your code including the ViewApply method
Attach your code to the button.

 
Ok, Thanks, I just needed that clarification.
 
Could you lead me to an area that demonstrates how to create a custom button?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top