manual caculation or automatic?

J

Joy

when users run our macros, if the project file is very large and complex, it
usually takes very long and the file may even get crashed.

I am thinking of change the calculation mode from automatic to manual. My
question is what bad consequences this operation may bring in? Will it skip
some important operations MS Project will do on the project? Are there any
better ideas? thanks,
 
J

Jack Dahlgren MVP

You can set it to manual at the start of your macro, then back to auto at
the end.
I have a few ideas to speed things up, but not sure they apply to your code.
Can you post the code here so we can take a look?

-Jack
 
J

Joy

thanks

1. save ms project in a csv file and send the file to our server. this may
take a a while and ms project is waiting for a response from the server. but
I dunt think this is the major issue.

2. we have a lot of procedures that iterate each task in the project file,
like:

For Each tsk In proj.Tasks
If Not tsk Is Nothing Then
tsk.Text24 = ""
End If
Next tsk

we have made some efforts to make it faster, and I am still interested in
how to make it faster

thank you!
 
J

Jack Dahlgren MVP

Considering batching up your iterations so that you don't need to iterate
multiple times.
Sometimes using a filter then working with all tasks at once is faster.

Things like this are sometimes surprisingly fast:

Sub Macro2()
' Macro Recorded 6/23/09 by jack.dahlgren.
SelectTaskField Row:=0, Column:="Text1"
SetTaskField Field:="Text1", Value:="x"
SelectTaskField Row:=0, Column:="Text1",
Height:=ActiveSelection.Tasks.Count
FillDown
End Sub
 
R

Rod Gill

Hi,

Try recording a macro of you selecting all cells in the column then pressing
delete. This clears everything in one go rather than task by task: much
quicker!

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
G

Gilgamesh

Rod Gill said:
Hi,

Try recording a macro of you selecting all cells in the column then
pressing delete. This clears everything in one go rather than task by
task: much quicker!


True but your column for the field in question needs to be in the same
position each time the macro is run. And with people inserting and deleting
columns as needed (at least that happens where I work) this could be a
problem.
You could get over this by the macro inserting the field into column
position 1 and then removing it when finished.
 
R

Rod Gill

Not true, the column is named so it can be anywhere. The following code
works wherever the column is inserted:

SelectTaskField Row:=0, Column:="Text1",
Height:=ActiveProject.Tasks.Count
EditClear Contents:=True


--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

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