Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: COM/DCOM/COM+
Expertise: Beginner
Jul 27, 1999

Using MS Word to Spell-Check in PowerBuilder

Question:
I need to incorporate Microsoft Word 97 spell-check functionality into PowerBuilder. Which MS Word functions are required to do the task?

Answer:
To interface to the Word spelling checker you will need to use OLE Automation to create a link to the Word application, then call the correct Word Basic functions.

The following code opens up the spelling checker dialog box for you. Note that you will need to convert any CR/LFs in PowerBuilder to CRs before calling the Word dialog box and then change the CRs back to CR/LFs after calling the module.

 
OleObject lole_Spell
Long ll_RC

SetPointer( HourGlass! )

// Word is available so replace all CR/LFs with CRs
this.ReplaceChar( as_Text, '~r~n', '~r' )

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

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.CheckSpelling()
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

// Change the CRs back to CR/LFs
this.ReplaceChar( as_Text, '~r', '~r~n' )
as_Text will now contain text with the correct spelling.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


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

 

 

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