having error with Microsoft.Office.Interop.MSProject.Application

U

urgent!!

I've referenced the COM object of MS Project but when I copy the code below
and run it in vb.net I get error during design time saying that type
Microsoft.Office.Interop.MSProject.Application is not defined. what does it
means?

Dim pj As New Microsoft.Office.Interop.MSProject.Application
pj.Visible = True
pj.FileOpen(txtSourceFile.Text.ToString())
Debug.Print(pj.ActiveProject.Name)
Debug.Print(pj.ActiveProject.Tasks.Count)
Dim tsk As Microsoft.Office.Interop.MSProject.Task
For Each tsk In pj.ActiveProject.Tasks
Debug.Print(tsk.Name)
Next
 
J

Jim Aksel

A Design Time Error? In VB.NET, this would mean the term is underlined with
a blue wavy line. If that is the case, then you have not correctly
referenced the object. I just tried it with both Project11 and 12 and they
both work fine on this machine.

I can reproduce a runtime error only under three conditions.

1. No reference defined for MS Project object.
2. pj.FileOpen(txtSourceFile.Text.ToString())

This line assumes the existance of a TextBox on the form named txtSourceFile
and there is a complete path entered into txtSourceFile. That is, you have
to assign the text property of txtSourceFile to a project file. Example:

txtSourceFile.Text="C:\Folder\Project1.mpp"
Actually, any string will work:

pj.FileOpen("C:\abc\myProjectFile.mpp")

Do you have a blue line under txtSourceFile indicating the object is not
defined?
Sorry for getting elementary, I just want to cover all the bases.

3. When I try to use Visual Studio 2005 on my Vista box, even with the
Service Pack and hot fixes for Vista installed.

I am using a development environment of XP SP2 and VS2005 with all patches,
etc applied.

I'll be happy to ZIP my solution for you and send it to you. I am at
jeaksel at yahoo dot com. If it doesn't work for you, it is a setting in
your development environment.
--
If this post was helpful, please consider rating it.

Jim

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

urgent!!

Yes, the term Microsoft.Office.Interop.MSProject.Application is underlined
with blue line. I've followed the way of referencing the MS Project object
suggested by you few weeks ago. I've enclosed 2 screen shots of the reference
and the error produced in the email I've sent to you. If you don't mind could
you take a look at it. My email is (e-mail address removed)
 
J

Jim Aksel

I'll send you my sln file as well. I don't know where you are, I am in the
United States. Today is Thanksgiving, a national holiday, and most people
are off work until Monday.

So, I will look into it... keeping in mind "Family Time"

Jim
 
U

urgent!!

I'm in Malaysia. Anyway, thanks for giving your time in helping me. I will
wait for your file. Happy Thanksgiving day..
 

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