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 a macro automatically

Status
Not open for further replies.

vidamj

IS-IT--Management
Apr 27, 2005
13
0
0
US
Is there a way to get a macro to run automatically. I use a macro to update my custom fields (i have a task field on the resource usage view) and a hot key of ctrl-m to run the macro. But sometimes even I forget to run it to update the data. any suggestions on this?
 
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.

 
Do I understand you correctly? Have you been able to update a custom field on the resource usage view with the contents of a field defined on the task usage view. If so, please tell me how you did it.
 
Yeah, it's quite easy but, as I said elsewhere, there are some things you have to consider.

You want to copy data from a task (let's say task field Text1) to a resource (let's store it in resource field Text2).

What happens when the resource is on multiple tasks? If you copy the data from every Task.text1 where the Resource is assigned over to the Resource.text2 then you will end up storing the Task information from only the last Task.text1 where the Resource is assigned.

In other words, just because you *can* do it doesn't always mean it makes sense *to* do it.

Sub doit()
' Copy Task.Text1 to Resource.Text2

Dim aa As Assignment
Dim rr As Resource
Dim tt As Task

For Each rr In ActiveProject.Resources
For Each aa In rr.Assignments
rr.Text2 = ActiveProject.Tasks(aa.TaskID).Text1
Next
Next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top