devxlogo

CreateOleObject errors

CreateOleObject errors

Question:
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.

Answer:
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 isin the debugger! So follow the steps below. Once you do, you’ll be able to at least get an errormessage 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:
    try     …some stuff   except on ExceptVar:      with ExceptVar do        ShowMessage(Message);   end;
    This will tell you what error message was generated with the exception, andhopefully tell you what’s going on with your application when it tries toestablish an OLE conversation.

    See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist