The version number detection methods need to be updated in several locations to allow events to be triggered on TOpOutlook.
Here are the adjustments that I have made to my own instance:
OpShared.pas
Approx line 97:
TOpOfficeVersion = (ovUnknown, ov97, ov98, ov2000, ovXP, ov2003, ov2007, ov2010); {!!.63}
Update the following method
function TOpOfficeComponent.ParseOfficeVersion(VersionStr: string): TOpOfficeVersion;
var
P, MajorVer, Code: Integer;
begin
Result := ovUnknown;
if (VersionStr <> '') then
begin
P := AnsiPos('.', VersionStr);
if P > 1 then
VersionStr := Copy(VersionStr, 1, P - 1);
Val(VersionStr, MajorVer, Code);
// Version number out of date. Updated by Cameron Mathers 2010-02-05 (YYYY-MM-DD)
// cmathers@coretec.com.au
// Version Numbers can be found at
// http://en.wikipedia.org/wiki/Microsoft_Office
if (Code = 0) and (MajorVer = 9) then {!!.63}
Result := ov2000 {!!.63}
else if (Code = 0) and (MajorVer = 10) then {!!.63}
Result := ovXP {!!.63}
else if (Code = 0) and (MajorVer = 11) then {Office 2003 Version 11}
Result := ov2003
else if (Code = 0) and (MajorVer = 12) then {Office 2007 Version 12}
Result := ov2007 {Apparently Version 13 was skipped due to superstition relating to the number 13}
else if (Code = 0) and (MajorVer = 14) then {Office 2010 Version 14}
Result := ov2010
else
Result := ov97;
end;
end;
OpOutlk.pas
Update the following method:
function TOpOutlook.CreateInstance: _Application;
var
TestName: WideString;
TestDispID: TDispID;
begin
{$IFDEF TRIALRUN}
_CC_;
_VC_;
{$ENDIF}
// Since Outlook 2000's Appliation coclass has a different GUID than
// Outlook 98, we first try to create an Outlook 2000 instance. If that
// fails, we then try to create an Outlook 98 instance. Outlook 97 will also
// respond to this CoCreate, so we must check to make sure we're not
// talking to Outlook 97. If all fails, an exception is raised.
if CoCreate(OpOlkXP.CLASS_Application_, _Application, Result) = S_OK then
begin
// Version number out of date. Updated by Cameron Mathers 2010-02-05 (YYYY-MM-DD)
// cmathers@coretec.com.au
// Version Numbers can be found at
// http://en.wikipedia.org/wiki/Microsoft_Office
if Pos('14.', Result.Version) > 0 then
FOfficeVersion := ov2010
else if Pos('12.', Result.Version) > 0 then
FOfficeVersion := ov2007
else if Pos('11.', Result.Version) > 0 then
FOfficeVersion := ov2003
else if Pos('10.', Result.Version) > 0 then {!!.63}
FOfficeVersion := ovXP {!!.63}
else if Pos('9.', Result.Version) > 0 then {!!.63}
FOfficeVersion := ov2000
else {!!.63}
FOfficeVersion := ovUnknown; {!!.63}
end
else if CoCreate(OpOlk98.CLASS_Application_, _Application, Result) = S_OK then
begin
TestName := 'Version';
// "Version" property is unsupported under Outlook 97, so that is the litmus test
if Result.GetIDsOfNames(GUID_NULL, @TestName, 1, GetThreadLocale,
@TestDispID) <> S_OK then
begin
Result := nil;
FOfficeVersion := ovUnknown;
OfficeError(SOl97NotSupported);
end;
FOfficeVersion := ov98;
end
else begin
FOfficeVersion := ovUnknown;
OfficeError(SFailCreateOutlook);
end;
end;