Accessing MS Project Data Using VB

C

Chris Molland

Hello,

I am about to develop an application in VB (Visual Studio 2005) which
enables a user to create new MS Project Tasks, edit and delete existing
Tasks. When creating new Tasks engineering data is looked up in data tables,
developed using SQL Server 2005 Express, and used to populate some of the MS
Project Task fields including some Custom Fields. My VB application will also
be communicating with Excel and a 3D engineering application. The complete
solution will be deployed on a standalone laptop.

My VB application will need to display a table (datagrid) of current Tasks
showing Task ID, Start Date and Name. This will allow the user to select a
Task to edit or display related information in the 3D engineering software.

I developed a working prototype using MS Project 2007 (Standard Edition) but
the only way I could maintain synchronisation between MS Project and the Task
list in my VB application was to loop through all the MS Project Tasks and
read them in every time I returned to my VB application window. This assumed
that by leaving the VB application window the user could change the MS
Project Task information.

Finally to my question (you have been very patient!). How can I access the
MS Project 2007 data directly from my VB application? It would be so much
more efficient if the information displayed in my VB application was the
actual MS Project data and not a copy of it held in a SQL data table.

Is it possible to configure MS Project to store its data in SQL data tables
which I could access from my VB application. Does this require MS Project
2007 Professional and a MS Project Server to be running on the laptop?

Thank you very much for looking at this and I look forward to your thoughts.
 
B

Brian Tkatch

Hello,

I am about to develop an application in VB (Visual Studio 2005) which
enables a user to create new MS Project Tasks, edit and delete existing
Tasks. When creating new Tasks engineering data is looked up in data tables,
developed using SQL Server 2005 Express, and used to populate some of the MS
Project Task fields including some Custom Fields. My VB application will also
be communicating with Excel and a 3D engineering application. The complete
solution will be deployed on a standalone laptop.

My VB application will need to display a table (datagrid) of current Tasks
showing Task ID, Start Date and Name. This will allow the user to select a
Task to edit or display related information in the 3D engineering software.

I developed a working prototype using MS Project 2007 (Standard Edition) but
the only way I could maintain synchronisation between MS Project and the Task
list in my VB application was to loop through all the MS Project Tasks and
read them in every time I returned to my VB application window. This assumed
that by leaving the VB application window the user could change the MS
Project Task information.

Finally to my question (you have been very patient!). How can I access the
MS Project 2007 data directly from my VB application? It would be so much
more efficient if the information displayed in my VB application was the
actual MS Project data and not a copy of it held in a SQL data table.

Is it possible to configure MS Project to store its data in SQL data tables
which I could access from my VB application. Does this require MS Project
2007 Professional and a MS Project Server to be running on the laptop?

Thank you very much for looking at this and I look forward to your thoughts.

Project Server stores the data in a database. The database can be
wherever, as long as Project Server can connect to it.

B.
 
C

Chris Molland

Thank you Brian. Does this mean that I can install and run MS Project Server
and MS Project Pro on the laptop simultaneously enabling MS Project to store
its data in a SQL database instead of a .mpp file?

Is this the only way to access the MS Project data directly? I was wondering
if MS Project 2007 Pro could store its data in SQL databases (accessed by my
VB application) without needing MS Project 2007 Server. There is only the 1
client.
 
J

Jan De Messemaeker

Hi,

No.
You can access the MS project application through automation, open the
project file and read the data directly.
 
B

Brian Tkatch

Thank you Brian. Does this mean that I can install and run MS Project Server
and MS Project Pro on the laptop simultaneously enabling MS Project to store
its data in a SQL database instead of a .mpp file?
Yes.

Is this the only way to access the MS Project data directly?

No. There are calls that can be made. But i am not familiar with them.
I was wondering if MS Project 2007 Pro could store its data in SQL databases (accessed by my
VB application) without needing MS Project 2007 Server. There is only the 1
client.

I don't know 2007, but in 2003, to get it in the database, Server is
required.

If you only have one client, Server is probably overkill. So, i'd try
to read the file in via calls. There should be an SDK or something to
help with that.

B.
 
C

Chris Molland

Thank you Jan,

So if I want to display the MS Project Task information within a VB form the
only way is to loop through all of the current tasks storing the data
temporarily for the VB application to display. There is no way I can
configure MS Project 2007 Pro to save its data to a database (on the same
computer as the client application) enabling my VB application to access the
same database to display/edit the data?

Thank you.
 
C

Chris Molland

Thanks Brian, this is interesting.

Do you happen to know if MS Project Pro (single user scenario) can store its
data in a local database rather than a .mpp file. This would allow me to
display the same synchronised data in a datagrid in my VB application. As I
change the task information in MS Project the VB application is immediately
updated by virtue of the fact they are both sharing the same database.

I know I can extract the information from MS Project using COM Interop as I
have done this, but it forces me to continually read all of the Task data
into my VB application because it cannot detect when the MS Project data
changes.

Regards

Chris
 
J

Jan De Messemaeker

Hi,

I'm afraid I'm nearly lost (about software I strictly only know Project) but
let me try.

In Project Pro (or for that matter, Standard), if you know the ID or the
nale or the UniqueID of the task you do not need to loop through all teh
tasks to get its properties.

Yes you can save a file to a data base and read anything from there. But if
you modify it Project's scheduling engine will not take into account these
changes until the project is opened in Pro or Standard.

Hope this helps,
 
B

Brian Tkatch

Thanks Brian, this is interesting.

Do you happen to know if MS Project Pro (single user scenario) can store its
data in a local database rather than a .mpp file.

My understanding is no, but i have no idea. I happen to use Project
Server, and we do a lot of reporting here, for which we are very happy
to have the DB access.
This would allow me to display the same synchronised data in a datagrid in my VB application. As I
change the task information in MS Project the VB application is immediately
updated by virtue of the fact they are both sharing the same database.

I would wonder how well that would work, read concurrency and all.
I know I can extract the information from MS Project using COM Interop as I
have done this, but it forces me to continually read all of the Task data
into my VB application because it cannot detect when the MS Project data
changes.

Actually, if you poll the modified date on the project file itself,
you should be able to get a good idea. FWIW, i'd refresh at regular
intervals, but let the user "force" an update sooner.

Just a thought.

B.
 
J

Jim Aksel

Information that can be read can always be written to a database, MS Project
2003 supports read/write to and from Access. You can also do it ODBC.
Project 2007 is not so straight forward -- you can read from an mpd database
file, or to Access. In Project 2007 desktop versions you can write out to
XML format.

XML will ultimately give you more flexibility but makes the programming a
bit more effort (IMHO)

So, usuing Visual Studio, you can open a project file (*.mpp) and read/wrtie
to any databse you desire using automation. If the file is saved as XML, you
will have to parse it. Either way, writing it to a 3rd party database should
be no problem.

I would suggest XML ... it can be sucked into nearly anything with the
correct schema. HTH.
--
If this post was helpful, please consider rating it.

Jim
It''s software; it''s not allowed to win.

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
C

Chris Molland

Thank you very much Jim. Such a help.

In my scenario the VB application and MS Project will be open simultaneously
allowing the user to move between the 2 windows at will. It seems very
straight forward to enable my VB application to access a Task and modify its
data. The modified value will then be immediately visible to the user.

What I am struggling with is to establish a method of displaying a list of
Tasks in my VB application, allowing the user to select one in the list,
without having to constantly read all the Tasks in from an external file.
This would allow the user to click on the MS Project window, move a Task in
the Gantt chart for example and the values in the VB application would
reflect the changes. For this reason I wanted to try and connect into the
actual source data which MS Project uses. I apologise for my lack of
knowledge in this area.

I didn't know I could save the MS project data out as an XML file. Does this
mean that you can Export the data in XML meaning that I would have to then
read it in and refresh the Task list in VB or cam MS Project be configured to
constantly read and write to an XML file which my VB application can be
connected to?

I appreciate your help here.

Regards

Chris
 
J

Jan De Messemaeker

Hi,

Again, IMHO, what you want to do should be done based on the values in the
open MSP file NOT through a DB.
However you would save the data there will never be an instant
synchronisation between the two.
I'm afraid you will have to learn the project objects.

And BTW in a previous post I told you you don't always have to read all
Project tasks to locate one.
And by all means, executing a For each task loop is so fast that I fail to
see any problem there.
HTH
 
J

John Sitka

This would allow me to display the same synchronised data in a datagrid in my VB application.

No, it wouldn't unless Project made a CRUD call with every click of the mouse or keystroke.

Real Time exists in the Objects, not the persistance layer.
so even if you bound your VB to 'the database', there would be no
gaurentee of timely or similar values at any one moment.
 

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