Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Activating Word Window
Message
 
 
To
25/06/2010 19:45:29
Hong Yew
People Quest
Malaysia
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01470664
Message ID:
01470668
Views:
49
>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	&& Minimize  
  loWord.WindowState = wdWindowStateMaximize	&& Maximize and it automatically activates the window
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform