I am using Borland Delphi 6, accessing the MS Project data structure via its
type library. One of the things I have done is imported the msproj9.olb and
renamed it as a unit to my application. This opens up the entry points for
my application to retrieve and write data from/to the MS Project file. I can
interact with the MS Project file directly.
An extract of the pertinent section is attached. It is located starting on
line 5130 of the Type library:
// *********************************************************************//
// Interface: Calendar
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {000C0C43-0000-0000-C000-000000000046}
// *********************************************************************//
Calendar = interface(IDispatch)
['{000C0C43-0000-0000-C000-000000000046}']
function Get_Name: WideString; safecall;
procedure Set_Name(const retval: WideString); safecall;
function Get_Parent: IDispatch; safecall;
function Get_Application_: Application_; safecall;
function Period(Start: OleVariant; Finish: OleVariant): Period; safecall;
function Get_Years: Years; safecall;
function Get_WeekDays: WeekDays; safecall;
procedure Reset; safecall;
function Get_BaseCalendar: Calendar; safecall;
procedure Delete; safecall;
function Get_Index: Integer; safecall;
property Name: WideString read Get_Name write Set_Name;
property Parent: IDispatch read Get_Parent;
property Application_: Application_ read Get_Application_;
property Years: Years read Get_Years;
property WeekDays: WeekDays read Get_WeekDays;
property BaseCalendar: Calendar read Get_BaseCalendar;
property Index: Integer read Get_Index;
end;
Having this information, do you have any additional insight as to how I can
obtain access to this data.
The other part of the question involved the MDB view of the calendar
information.
The columns titles relate to the above fields in the type library, I
believe.
The Cal_UID refers to the project calendar. The 1st 7 lines contain the
normal workweek schedule, identifying weekend and work hours for the
workdays. The following lines identify date ranges for exception non-work
time, like Start(11/24/05) and Finish(11/25/05), meaning all days with in the
range are non-work. These dates are stored as TDateTime data within the
structure but are communicated as OleVariants through the type library
interface. One needs to take the OleVariant data and perform a data
conversion to a TDateTime data structure.
Does this additional information help you in formulating an answer. If you
look at my original question, I am looking for the Data Structure string
format I should use to first, get to this data structure and 2nd, to access
the Start and Finish dates for each of the holiday date ranges in order so I
can load them into my electronic calendar for local calculations.
Thanks for your help
Jan De Messemaeker said:
Hi,
I do not use this road to access Project's objects (but the VBA way) so I'm
not 100% sure but AFAIK the Period object simply does not have a Start
property.
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
http://users.online.be/prom-ade/
+32-495-300 620
project-guy said:
I am accessing MS Project 2000 via the Type Library, msproj9.olb, found in
the install filepath of the application.
Within the olb is a segment for the calendar. i am trying to access the
Calendar holiday list by using the following:
var Holiday :Olevariant;
Start, finish :TDateTime;
HolidayIndex :integer;
begin
HolidayIndex := aHol;
holiday:=
ProjectApp.Projects[Projectname].calendar[holidayindex].period(Start,Finish)
;
result := holiday.start;
end;
aHol is the integer index into the segment. This approach is not working
but is returning a "0" value, suggesting a date was not found. I
saved
the
file as an MDB and accessed the MSP_Calendar_Data table and am using the
first record in the table matching the particular calendar being used
by
the
task ( and project).
Can anyone offer a suggestion as to the proper way to reference and return
the Start and Finish dates held in the calendar.period segment of the data
structure?
thanks