1. Kevin Thai
  2. PowerBuilder
  3. Tuesday, 26 April 2022 20:32 PM UTC

Hi all,

 

I am currently on PB 2021 Build 1506, and am trying to add Microsoft Word Spell and Grammar check into our Application. I am able to get the SpellCheck to work, however most of the time the window popups behind everything and make it often look like the Application has frozen unless you know to ALT+Tab to find the window. We currently want to make the Microsoft Word invisible expect for the Spell and Grammar Window. I did find some old post about this very same issue, using SetForegroundWindow((ll_Hwnd)) , SetActiveWindow(ll_Hwnd) , BringWindowToTop(ll_Hwnd) to bring the window up. My issue right now is since Powerbuilder waits for the Spellcheck window to close before running the next line of code, is there a way to trigger the bringtotop function while Powerbuilder is waiting? Or if anyone has a better solution please let me know. I will post my code for reference

Your help is much appreciated! 

 

Here is code for grammar check execution:

string	as_text
Long ll_RC


// Connect to Word and do a spell-check
lole_Spell = CREATE OleObject
ll_RC = lole_Spell.ConnectToNewObject( 'Word.Application' )
IF ll_RC <> 0 THEN
	DESTROY lole_Spell
	
END IF

as_text = sle_1.text
lole_Spell.Application.Visible = false
lole_Spell.Application.WindowState = 2
lole_Spell.Documents.Add()
lole_Spell.Selection.TypeText( as_Text )
lole_Spell.Selection.HomeKey()
lole_Spell.Selection.MoveStart()
lole_Spell.ActiveDocument.CheckGrammar()
lole_Spell.ActiveDocument.Select()
as_Text = lole_Spell.Selection.Text
lole_Spell.ActiveDocument.Close( False )
lole_Spell.Application.Quit
lole_Spell.DisconnectObject()
DESTROY lole_Spell

sle_1.text = as_text

 

Code for BringToTop of Window

string ls_null

SetNull (ls_Null)

// Get handle of Spell Check window
ll_Hwnd = FindWindowA ( ls_Null, 'Spell and Grammar Check') 
SetForegroundWindow((ll_Hwnd))
SetActiveWindow(ll_Hwnd)
BringWindowToTop(ll_Hwnd)
Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 26 April 2022 21:25 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi,

I'm not sure if you might have seen one of my previous posts:

Regards,

MiguelL

 

Comment
There are no comments made yet.
karimi Manizhe Accepted Answer Pending Moderation
  1. Thursday, 16 June 2022 12:25 PM UTC
  2. PowerBuilder
  3. # 1

Microsoft Word includes a number of proofing tools, such as the Spelling and Grammar tool, that can assist you in producing professional, error-free documents.

To run a Spelling and Grammar check:

  1. From the Review tab, click the Spelling & Grammar command.
  2. The Spelling and Grammar pane will appear on the right. For each error in your document, Word will try to offer one or more suggestions. You can select a suggestion and click Change to correct the error.
  3. Word will move through each error until you have reviewed all of them. After the last error has been reviewed, a dialog box will appear confirming that the spelling and grammar check is complete. Click OK.

If want to go online grammar check then try this handy tool https://grammica.com

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.