Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to activate another windows application from within VFP

541 views
Skip to first unread message

Stefan Wuebbe

unread,
Oct 14, 2002, 10:33:21 AM10/14/02
to
If you know the window title, you can use the FindWindow
API
#DEFINE SW_RESTORE 9
LOCAL lcWinName, lnHWnd
lcWinName = "Microsoft Word" && your window title here

DECLARE INTEGER BringWindowToTop IN WIN32API ;
LONG HWND
DECLARE INTEGER ShowWindow IN WIN32API ;
LONG HWND, LONG nCmdShow
DECLARE INTEGER FindWindow IN WIN32API ;
STRING, STRING

lnHWnd = FindWindow(0, m.lcWinName)
IF m.lnHWnd <> 0
ShowWindow(m.lnHWnd, SW_RESTORE)
BringWindowToTop(m.lnHWnd)
ENDIF


hth
-Stefan

"dinesh jain" <jain_...@hotmail.com> schrieb im Newsbeitrag
news:18ba01c2737d$213605d0$2ae2...@phx.gbl...
> hi,
>
> is there a command in visual foxpro to activate another
> windows application (for eg. MS Word) which is already in
> minimised mode thru the main visual foxpro application.
>
> i have been able to run a windows application by using the
> RUN command.
>
> but if i use the command again to bring the other windows
> application in front then it executes a new copy of the
> s/w again instead of just activating it.
>
> is there any way that i can check for a windows
> application already open and if so then
> just bring it in front of my VFP application.
>
> thanks in advance.
>
> regards,
> dinesh
>

Chris Kefel

unread,
Oct 14, 2002, 10:28:49 AM10/14/02
to
Hi Dinesh,

Try:
oWord=CREATEOBJECT("Word.application") && open Word
oWord.documents.OPEN("d:\data\cdcover.doc") && open doc-file
*!* In between put the edited version of the macro you recorded in Word
*!* which means, the thing you want to do in Word, you have to do it
*!* Word and record it in a macro.
*!* Put the result here adding oWord. in front.
oWord.ActiveDocument.PrintOut && print
document
oWord.ActiveDocument.SaveAs("d:\data\cdcover.doc") && save document as
....
oWord.ActiveDocument.CLOSE(.F.) && close
document
oWord.APPLICATION.QUIT && close Word
--

Succes,

Chris

--
"dinesh jain" <jain_...@hotmail.com> schreef in bericht

Fred Taylor

unread,
Oct 14, 2002, 11:00:53 AM10/14/02
to
You can use GETOBJECT() if the application is already running.

oW = GETOBJECT(,"word.application") && note the leading comma!!!

oW now contains a reference to the running instance of Word.


--

Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.

dinesh jain wrote:
> hi,
>
> is there a command in visual foxpro to activate another
> windows application (for eg. MS Word) which is already in
> minimised mode thru the main visual foxpro application.
>
> i have been able to run a windows application by using the
> RUN command.
>
> but if i use the command again to bring the other windows
> application in front then it executes a new copy of the
> s/w again instead of just activating it.
>
> is there any way that i can check for a windows
> application already open and if so then
> just bring it in front of my VFP application.
>
> thanks in advance.
>
> regards,
> dinesh


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.401 / Virus Database: 226 - Release Date: 10/9/2002


0 new messages