Forum Discussion
Jamesp435
Feb 02, 2022Brass Contributor
MS Project VBA running a macro with a field change...
Hi team On the off chance, is it possible when you change a field (say duration) it will automatically run a macro? Many thanks James
- Feb 02, 2022
Hello Jamesp435 ,
I've not tried it but this might help https://docs.microsoft.com/en-us/office/vba/api/project.project.change
Paul
John-project
Feb 02, 2022Silver Contributor
Jamesp435,
Paul provided an excellent reference, let me add a word of caution. The Change Event has been available since the early days of Project VBA but it must be used with care. Since the event is fired for every change, (with the exceptions noted in the article Paul referenced), the macro can slow things down considerably. If you want to limit the "slowdown" overhead I suggest you include a test at the beginning of the macro code that "bails out" if the change is not related to the field of interest.
John
Paul provided an excellent reference, let me add a word of caution. The Change Event has been available since the early days of Project VBA but it must be used with care. Since the event is fired for every change, (with the exceptions noted in the article Paul referenced), the macro can slow things down considerably. If you want to limit the "slowdown" overhead I suggest you include a test at the beginning of the macro code that "bails out" if the change is not related to the field of interest.
John
- Jamesp435Feb 02, 2022Brass ContributorThat's a good point John. That's what I did when doing a lot of Visio VBA a while back... Cheers
- John-projectFeb 02, 2022Silver ContributorJames,
You're welcome and thanks for the feedback.
John