Command execution sequence in VBA

C

Cevikel

HI NG ,
I am using a small macro ( VBA ) in my ms project file doing various things.
The command in the first line is - Application.CalculateAll -. Then other
commands
follow. But while executing this macro the command Application.CalculateAll
is
always executed last behind all other commands although it is placed first.
Can anyone explain why.
Thanks in advance.
 
R

Rick Williams

Do you have automatic calculation turned on? If so it may be calculating
every time a change is made?
Rick
 
J

John

Cevikel said:
HI NG ,
I am using a small macro ( VBA ) in my ms project file doing various things.
The command in the first line is - Application.CalculateAll -. Then other
commands
follow. But while executing this macro the command Application.CalculateAll
is
always executed last behind all other commands although it is placed first.
Can anyone explain why.
Thanks in advance.

Cevikel,
First of all the newsgroup you have posted to is destined to be shut
down. The replacement newsgroup is: microsoft.public.project.develper.
Please post to that newsgroup for future questions.

To answer your question. Project performs its calculation after each
edit that affects cost or schedule, is made by the user. In simple
terms, Project needs to know what was changed in order to re-calculate.
So yes, Project does its calculation last although the code will
re-calculate (if necessary) as soon as it executes the calculate command.

You don't really need to tell Project to calculate because automatic
calculation is the default. Normally the calculate command in VBA is
only used if calculation was turned off at the beginning of the code.
This is often done if the code makes a lot of changes to the file. If
calculation if left on automatic the code will run slower because
Project will calculate after each change. By turning calculation off at
the beginning of the code, changes can be made en masse and then the
whole thing can be calculated by including the CalculateAll Method at
the end.

Hope this helps.
John
Project MVP
 

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