>Hi all
>
>I have code to launch Word from my VFP9 app as follows.
>
>But Word window is not the active window and my calling VFP9 app is still the active window.
>May I know if there is anyway for me to make the MSWord window the active window instead?
>
>Your advice much appreciated. Thanks & Best Regards
>
>
> if file(lcMergeDoc)
> **** Merge Word Document already exist
> DECLARE INTEGER ShellExecute IN Shell32.DLL INTEGER hwnd, ;
> STRING @lpOperation, STRING @lpFile, STRING @lpParameters, ;
> STRING @lpDirectory, INTEGER nShowCmd
> lcParms = ""
> lcDir = addbs(toApplication.ProjectDirectory)+'DOCS'
> lcFile = alltrim(juststem(tcOutputFileName))+'.DOC'
> lcOp = 'open'
> lnshow = 3
> lnError = ShellExecute(0, @lcop, @lcfile, @lcparms, @lcdir, lnshow)
> else
> **** No Word Merge document exist
> loWord = CREATEOBJECT('Word.Basic')
> loWord.FileNewDefault
> loWord.MailMergeMainDocumentType(0)
> loWord.MailMergeOpenDataSource(tcOutputFileName,0,0,1,0,'','',0,'','','','','')
> loWord.MailMergeEditMainDocument
> if toApplication.lDebug
> messagebox('Save Merge Doc as :'+addbs(toApplication.ProjectDirectory)+'docs\'+ALLT(juststem(tcOutputFileName))+'.DOC')
> endif
> loWord.FileSaveAs(addbs(toApplication.ProjectDirectory)+'DOCS\'+ALLT(juststem(tcOutputFileName))+'.DOC')
> loWord.AppMaximize
> loWord.AppShow
> endif
From Russian FAQ:
http://forum.foxclub.ru/read.php?32,177182,258927#msg-258927 #DEFINE wdWindowStateMinimize 2
#DEFINE wdWindowStateMaximize 1
loWord.WindowState = wdWindowStateMinimize
loWord.WindowState = wdWindowStateMaximize
If it's not broken, fix it until it is.
My Blog