Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Interaction between Excel and Microsoft Project

Status
Not open for further replies.

theburst

Technical User
Jun 27, 2007
9
US
There is probably a basic answer to my question, however I don't have the programming background to find it and have been trying to figure it out for a day now.

Here goes.

I'm writing a macro that will place Tasks in the network diagram (in Microsoft Project) in specific locations (so the user can create and see visually dependencies of smaller groups of tasks). The macro calls an excel file which has three columns of information. The excel file contains the UniqueID, XPosition, and YPosition.

My problem occurs when my macro tries to place a task that has already been deleted (in Microsoft Project), and the excel file still contains a reference to the Unique ID of the deleted task. When the macro tries to place the task that does not exist anymore, the code dies (as would be expected).

I need a way to check if that Unique ID still exists and if not just skip it(maybe provide user with a warning).

Code:
Set jTask = ActiveProject.Tasks.UniqueID(UniqueIDNum(I))

This is the line of code that gives me trouble. UniqueIDNum() is an array read from excel.

I thought of using something like an ON Error Resume, but I'm not entirely sure how to implement it.

Hope this is clear enough to understand.

Thoughts?
 
On Error Resume Next
Set jTask = ActiveProject.Tasks.UniqueID(UniqueIDNum(I))
If Err.Number <> 0 Then
Err.Clear
Else
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I think that will do it. Are there any major downsides to ignoring errors this way? I don't see a way around it for what I want to do.

Thanks for your help!
 
OOps, I've forgot one line:
On Error Resume Next
Set jTask = ActiveProject.Tasks.UniqueID(UniqueIDNum(I))
If Err.Number <> 0 Then
Err.Clear
Else
On Error GoTo 0
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top