VB Read All Project Tasks

C

Chris Molland

Hello, and thanks for reading this post.

I am developing an application in Visual Basic which has to keep a DataTable
synchronised with the Tasks in a Project file. To do this I currently
itterate through the Tasks in a Project reading the required fields into a
DataRow and add this DataRow to a DataTable.

It works reliably. . . . but very slowly.

Is it possible to get the complete Tasks collection in one API call and then
extract the data from within my application which may be far quicker?

If only I could directly access the data in the MS Project file!

Thank you for your help.

Regards

Chris
 
R

Rod Gill

The fastest way I know is to have a macro in Project VBA that you call that
reads all data into an array that you then save to your application. You can
try just reading from your application, but that will be inter-process
unless you create a project add-in (easier in 2003 and 2007).

--

Rod Gill
Microsoft MVP for Project

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

Chris Molland

Thank you Rod,

I will look at implementing your suggestion for triggering a VBA macro.

My scenario is that if my application loses focus then there is no way of
knowing if the MS Project data has been changed by the user, which they
should be allowed to do if they want. When my applications regains focus it
has to read all of the Task data in to refresh my SQL database. Is there any
way of identifying Tasks which have changed, like you can in a SQL table?
This way I could set all the Tasks to "clean" when I leave MS Project and
then when I return only read in the Tasks which are "dirty". Just a thought.

Thanks again Rod.

Regards



Chris
 
R

Rod Gill

There is no dirty flag and whilst you could set a custom flag field, there
isn't a reliable way of resetting the flags if someone changes data. It may
be best to have a macro export data with a "Publish" function then make part
of the solution process and training.

--

Rod Gill
Microsoft MVP for Project

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

Chris Molland

Thanks Rod,

I think I will create a MS Project 2007 Add-In and call methods from this to
return all of the Task data I want. I may be able to use this to enable MS
Project to "look after itself". If there is an event which recognises that
the application is losing focus then the Add-In can export all of the Task
data to my SQL table by itself.

I'll experiment and see what is available to me. It would be so good if
Project Pro could store its data in an SQL database in a standalone scenario.
Oh well!

Thank you again.

Chris
 
R

Rod Gill

You need to write your own code to save to database in 2007. There isn't an
application losing focus event that I'm aware of.

--

Rod Gill
Microsoft MVP for Project

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

Chris Molland

Thank you for letting me know about the event, or non-event as the case may be!

I have written my Add-In for Project 2007 which activated and provides a
service OK. I added a simple button on a new Command Bar to display a message
to prove its functionality.

I created a new Class in my Add-In (named "projUtilities") which I placed a
test method in (named "hello").

In my own application I added a reference to the Add-In but just can't seem
to find a way to call the "hello" method in the Add-In.

I intend to call a function in my Add-In which will create a DataTable, add
the Task data which I want into new DataRows in the DataTable and return the
DataTable. This will enable my application to gather all of the Task data
which I need, to place into my SQL table, with a single API call.

Any advice as to how I get a reference to the projUtilities Class in my
Add-In so that I can call my method would be very helpful.

Thank you.
 

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