using vba ms project, 1 of command datedifference.
differencedate = application.datedifference(tsk.baselinestart, tsk.baselinefinish, activeproject.calendar)
however, trying use vsto ms project, can figure out how use datedifference. there equivalent command cor c#?
you can use same exact ms project vba method in vsto. change application
msproject.application variable name , preface activeproject
variable. example, if variable name projapp
use this:
differencedate = projapp.datedifference(tsk.baselinestart, tsk.baselinefinish, projapp.activeproject.calendar)
the returned value duration in minutes between dates, same when use in vba.
bottom line: if want same calculation in vba, use method. if want elapsed time between dates use c#'s built-in date math functions. former relevant when dealing ms project dates cpm-driven.
update: tested in c# , found datedifference
method throws notimplemented
exception (but works fine in vb.net). since method way accurately calculate duration between 2 dates, can use vb.net part adding separate (vb) project within solution.
update 2: here vb.net class can call c#:
imports microsoft.office.interop public class msprojectmethods public function msprojectdatedifference(byval projapp msproject.application, byval startdate datetime, byval finishdate datetime) int32 dim returnvalue object = projapp.datedifference(startdate, finishdate) if isnumeric(returnvalue) return convert.toint32(returnvalue) else throw new system.exception("an exception has occurred.") end if end function end class
and here's how can call it:
classlibrary1.msprojectmethods mspvb = new classlibrary1.msprojectmethods(); int differencedate = mspvb.msprojectdatedifference(projapp, convert.todatetime(tsk.baselinestart), convert.todatetime(tsk.baselinefinish));