An unexpected error occured with the method

D

Daniel Engelschalt

Hi,

using Project 2003 SP2 I sometimes get the mentioned error message.
This happens when I use SelectTaskField or SelectTaskColumn. Even when
I record a macro and let it run immediatly after stopping the
recording, this happens. Sometimes it works if I restart MS Project,
sometimes not.
MS Knowledge Base tells me something about setting absolute IDs as a
preference for recording a macro-it doesn't help. But it nevertheless
should work if I only use VBA code.

Do you have any ideas about this problem?

Daniel
 
R

Rod Gill

Hi,

What's the code that causes the problem? Moving the cursor to tasks to
read/write data is completely unnecessary and causes slow and problematic
code. For example if you try to move to a task that has been filtered out or
to a sub-task that is not visible your code errors out.

Use:
activeproject.tasks("My Task").work=8*60

Don't move to the task then edit, it simply isn't robust!
 
D

Daniel Engelschalt

Hi Gill,

Thank you for your fast response.

My function starts with:

SelectTaskColumn Column:="Indicators", Additional:=3

as the very first command.

The goal is to mark all tasks, outline and analyze them and after a
task has been analyzed mark these that match a given condition.
To mark tasks I use SelectTaskField for which I first have to outline
all tasks (row).
A command like activeproject.Tasks(currentTask.ID).font.color=1 could
be helpful, but I haven't found something like this.

Daniel
 
R

Rod Gill

So why are you selecting the columns? If the indicator column isn't visible
your code will crash, one of many reasons why moving the cursor in a vba
macro is poor programming, slow and expensive to develop!!
 
D

Daniel Engelschalt

Hi Gill,

What is the correct way to mark a task and assign another font or
background color to indicate that something is wrong there? All
functions I have found are cursor-related. As I have written below
something like: activeproject.Tasks(currentTask.ID).font.color=1 would
be helpful.

Thanks,
Daniel
 
J

Jan De Messemaeker

Hi Daniel,

Matter of fact, Font only works on the selection.
Beware, you talk about background color, in any of the commercially
available versions that doesn't exist.
But where Rod definitely has a point, why select a column?

HTH
 
D

Daniel Engelschalt

Hi Jan,

What I am trying to do is to mark tasks. I think it is user friendly to
do this by changing the font color of this task. As you have written
below, font stuff only works on a selection - so I have to outline all
tasks to move to that specific task whose font I want to change. I do
this because SelectTaskField only works with row:=myTask.ID. And this
leads to selecting e. g. the 50th visible task and not the 50th task of
the whole project which I wanted to select. So first I have to outline
all tasks and then select the one I need.

But it seems that this is not the appropriate way to indicate something
to the user. Maybe a plain listbox (without being able to click on a
task and moving to it) does this job.

Thanks,
Daniel
 
R

Rod Gill

There is an old field called the Marked Task. I think it was created before
Flag fields were added and it has survived since then for backwards
compatibility.

A good thing about the Market Task flag is that you can have a text style
for it. So, set Marked to True then under Format, Text Styles, format how
you want a marked task to go.

Now as your VBA code marks and unmarks tasks, the format changes
automatically: no need to select tasks at all!!
 

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