Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Pascal
Expertise: Beginner
May 9, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

CreateOleObject errors

My completed Delphi application exports Quick Reports to Excel. This operation is 99.5 percent successful, and users are delighted. I am one of the developers, and one of the .5 percent. Before the app was released, my peer developers decided the problem was my machine (a Dell). The .5 percent of the users are screaming. I need to know why it isn't working for some of us so that I can fix it right away.

The code is written with TRY/FINALLY and is failing within the CreateOleObject('Excel.Application'). I want to be able to capture the exact error# and description so I can correct it.

The answer to this question is not specifically geared towards the OleObjectError message. It's a more generic technique that can be applied to various exceptions that arise in Delphi programs.

There's no "easy" way to figure out error messages before they actually occur. In fact, for handling errors, you won't know what to handle until you see what the darn message is in the debugger! So follow the steps below. Once you do, you'll be able to at least get an error message you can use.

  1. Open up the code in the IDE
  2. Change the finally in your try..finally..end to "except." This'll raise an exception when it occurs.
  3. Run the program and get to the exception. You should get a message box that tells you the exception class. Write the exception down, or at least remember what it is.
  4. Break out of the program and reboot if you have to.
  5. Go back to the source code in the IDE and change the except in your try block to the following:
         ...some stuff
       except on ExceptVar: 
         with ExceptVar do
    This will tell you what error message was generated with the exception, and hopefully tell you what's going on with your application when it tries to establish an OLE conversation.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date