Board index » delphi » Project1.dpr(17):error object or class type required

Project1.dpr(17):error object or class type required

Here is the error i get when i try to do some ole automation.
This happends when i try to use the imported type library from outlook.
I put "outlook_tlb" in my uses clause.

What can i do to solve this problem ?

I have to tell you that i am used to do OLE automation like this :
USES ... , ComObj, ... ;

type
  TMain = class(TForm)
    ToolButton2: TToolButton;
    ToolButton1: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    procedure ToolButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
     MsOutlook, MyNameSpace, MyAddressLists, MyFolder,
     MyItem, MyNotes, MyAttach : variant;
  end;

procedure TMain.FormCreate(Sender: TObject);
begin
   try
      try
         MsOutLook := GetActiveOleObject('Outlook.Application');
//         MsOutLook := CoApplication.Create();
      except
         MsOutLook := CreateOleObject('Outlook.Application');
      end;
   except
      Screen.Cursor := crDefault;
      ShowMessage('Could not start Microsoft Outlook.');
//      Application.Terminate;
   end;
   MyNameSpace := MsOutLook.GetNameSpace('MAPI');
   MyAddressLists := MyNameSpace.AddressLists;
   MyFolder := MyNameSpace.GetDefaultFolder(olFolderContacts);
   myItem := MsOutlook.CreateItem(olMailItem);
   MyNotes := MsOutlook.CreateItem(olNoteItem);
   MyAttach := MyItem.Attachments;
end;

 

Re:Project1.dpr(17):error object or class type required


Hello,

I haven't imported Outlook but make sure that there is actually a
CoApplication class in the outlook_tlb file.

have fun,

--
Binh Ly
Brickhouse Data Systems, Inc.
http://www.brickhouse.com

Quote
Godinas-Andrien alain wrote in message <35A4CF3D.49782...@addx.be>...
>Here is the error i get when i try to do some ole automation.
>This happends when i try to use the imported type library from outlook.
>I put "outlook_tlb" in my uses clause.

>What can i do to solve this problem ?

>I have to tell you that i am used to do OLE automation like this :
>USES ... , ComObj, ... ;

>type
>  TMain = class(TForm)
>    ToolButton2: TToolButton;
>    ToolButton1: TToolButton;
>    ToolButton3: TToolButton;
>    ToolButton4: TToolButton;
>    procedure ToolButton2Click(Sender: TObject);
>    procedure FormCreate(Sender: TObject);
>    procedure ToolButton1Click(Sender: TObject);
>    procedure ToolButton4Click(Sender: TObject);
>  private
>    { Private declarations }
>  public
>    { Public declarations }
>     MsOutlook, MyNameSpace, MyAddressLists, MyFolder,
>     MyItem, MyNotes, MyAttach : variant;
>  end;

>procedure TMain.FormCreate(Sender: TObject);
>begin
>   try
>      try
>         MsOutLook := GetActiveOleObject('Outlook.Application');
>//         MsOutLook := CoApplication.Create();
>      except
>         MsOutLook := CreateOleObject('Outlook.Application');
>      end;
>   except
>      Screen.Cursor := crDefault;
>      ShowMessage('Could not start Microsoft Outlook.');
>//      Application.Terminate;
>   end;
>   MyNameSpace := MsOutLook.GetNameSpace('MAPI');
>   MyAddressLists := MyNameSpace.AddressLists;
>   MyFolder := MyNameSpace.GetDefaultFolder(olFolderContacts);
>   myItem := MsOutlook.CreateItem(olMailItem);
>   MyNotes := MsOutlook.CreateItem(olNoteItem);
>   MyAttach := MyItem.Attachments;
>end;

Other Threads