Wednesday, April 11, 2012

How to Spell Check in Oracle Forms 6i ?

How will you feel if you able to check spelling in oracle forms?

Yea! Surely great…
Let’s try how we can do that.
This code uses the Microsoft Office spell checker, so you have installed Microsoft office suite. Now, create a procedure in forms under program units with the following code.

PROCEDURE spell_check (item_name IN VARCHAR2)
   my_application   ole2.obj_type;
   my_documents     ole2.obj_type;
   my_document      ole2.obj_type;
   my_selection     ole2.obj_type;
   get_spell        ole2.obj_type;
   my_spell         ole2.obj_type;
   args             ole2.list_type;
   spell_checked    VARCHAR2 (4000);
   orig_text        VARCHAR2 (4000);
   orig_text := NAME_IN (item_name);
   my_application := ole2.create_obj ('WORD.APPLICATION');
   ole2.set_property (my_application, 'VISIBLE', FALSE);
   my_documents := ole2.get_obj_property (my_application, 'DOCUMENTS');
   my_document := ole2.invoke_obj (my_documents, 'ADD');
   my_selection := ole2.get_obj_property (my_application, 'SELECTION');
   ole2.set_property (my_selection, 'TEXT', orig_text);
   get_spell :=ole2.get_obj_property (my_application, 'ACTIVEDOCUMENT');
   ole2.invoke (get_spell, 'CHECKSPELLING');
   ole2.invoke (my_selection, 'WholeStory');
   ole2.invoke (my_selection, 'Copy');
   spell_checked := ole2.get_char_property (my_selection, 'TEXT');
   spell_checked :=SUBSTR (REPLACE (spell_checked, CHR (13), CHR (10)),1,LENGTH (spell_checked));
   COPY (spell_checked, item_name);
   args := ole2.create_arglist;
   ole2.add_arg (args, 0);
   ole2.invoke (my_document, 'CLOSE', args);
   ole2.destroy_arglist (args);
   ole2.RELEASE_OBJ (my_selection);
   ole2.RELEASE_OBJ (get_spell);
   ole2.RELEASE_OBJ (my_document);
   ole2.RELEASE_OBJ (my_documents);
   ole2.invoke (my_application, 'QUIT');
   ole2.RELEASE_OBJ (my_application);

Now call the procedure in a Button passing the column name. Like

Now all is yours…  :)

Say thanks, if it helps.


  1. This comment has been removed by the author.

  2. Hi..
    i am using word 2007. the document opens but it does not copy the content from forms. and at time of opening word document gives error of document failure and recovers.


  3. Hi,

    Thank you for putting this out there. This is really helpful.

    Was testing this in my environment and noticed the spell check window is hidden in the background. I dont think my users will be willing to minimize their windows to get to the spell check window.

    Do you know how to make the spell check window display at the main window?

    I am using: Oracle forms 6i, database 11g, Windows 7 and office 2010.

    Thanks again for sharing this code.

    1. Please help...
      This code worked on oracle form builder 11g ??

  4. Hi Mohammad Hamidur,

    Thank you very for your code, that's really helpful. but I'm facing same problem as Andrew, any help.