Working with calendar object

S

Sergey E.

Hi guys,

Could anybody help me to understand how to add new exception (e.g. vacation)
to calendar using c# and VS2005? I need to add an exception for a particular
resource's calendar, not for everyone.

MS Project 2007

Thank you!
 
J

Jack Dahlgren

The syntax generated by recording a macro goes like this:
ActiveProject.Resources("the resource name").Calendar.Exceptions.Add
Type:=1, Start:="6/15/2009", Finish:="6/15/2009", Name:="name of your
exception"

You can parameterize the values which are used for Start, Finish and use an
index number for the resource. With that as a start it should be possible to
figure out the c# call.

-Jack
 
S

Sergey E.

I tried to call add method, but it throws an exception. I'm sure that format
of parameters match but something going wrong inside Interop library.

Here is some code to understand what I’m doing. Maybe I’m wrong somewhere
but regarding to this page
http://msdn.microsoft.com/en-us/library/bb178424.aspx everything looks fine.

Resource resource = DADataProvider
..Instance.Application.ActiveProject.Resources[resourceId];

resource.Calendar.Exceptions.Add(

PjExceptionType .pjYearlyPositional, vacation.Start, vacation.Finish, 0,
vacation.Type, 0, 0, 0, 0, 0, 0);

vacation.Start, vacation.Finish – objects of DateTime type, vacation.Type -
string

Any help would be very appreciated!
 

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