Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Riccardo Pimpini
  Where is Riccardo Pimpini?
 Firenze
 Italy
 Riccardo Pimpini
 Tags
Subject: RE: call Excel from VFP
Thread ID: 248784 Message ID: 248827 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Microsoft Office Automation
Date: Wednesday, December 23, 2009 4:43:31 PM         
   


> >
> > Ho Me's and Akram's automation suggestions would give you far more control - but for what it's worth, you can also use Vfp's Run command, or perhaps rather the ShellExecute() Win32API function, for example in pseudo code:
> >
> >
> > * Run
> > Local lcEXE, lcXLS
> > lcEXE = GETFILE('exe')
> > lcXLS = GETFILE('xls')
> > RUN /n &lcEXE. &lcXLS.
> > 
> > * ShellExecute 
> > Local lnSuccess
> > DECLARE INTEGER ShellExecute ;
> > 	IN SHELL32.DLL ;
> > 	INTEGER nWinHandle, ;
> > 	STRING cOperation, ;
> > 	STRING cFileName, ;
> > 	STRING cParameters, ;
> > 	STRING cDirectory, ;
> > 	INTEGER nShowWindow
> > lnSuccess = ShellExecute(0,'open',m.lcEXE,m.lcXLS,'',1)
> > 

> >
> >
> > hth
> > -Stefan
>
> I used:
>
>
Local lcEXE, lcXLS
> lcEXE = GETFILE('exe')
> lcXLS = GETFILE('xls')
> RUN /n &lcEXE. &lcXLS.

>
> IT WORKS!!!
>
> Thanks Stefan for now,
> i will let you know i i got some news...
>

Ciao Riccardo, glad to hear that it works :-)

ShellExecute() may even be better though: although the code looks more long-winded at first glance, you'd get rid of the ¯o(s) (which are less safe than (name) expressions, and require additional just-in-time compilation resources at runtime).
And the Run command itself is also a little less straight-forward because it is a very mature one, that even already existed in the old FoxPro For Unix / DOS / Win3.0 versions, and thus probably has some backwards-compatibility overhead internally, too.


Regards
-Stefan

ENTIRE THREAD

call Excel from VFP Posted by Riccardo Pimpini @ 12/23/2009 11:09:30 AM
RE: call Excel from VFP Posted by ho me @ 12/23/2009 11:15:39 AM
RE: call Excel from VFP Posted by Riccardo Pimpini @ 12/23/2009 11:31:44 AM
RE: call Excel from VFP Posted by M. Akram Bhatti @ 12/23/2009 11:36:59 AM
RE: call Excel from VFP Posted by Riccardo Pimpini @ 12/23/2009 12:06:32 PM
RE: call Excel from VFP Posted by M. Akram Bhatti @ 12/23/2009 12:11:58 PM
RE: call Excel from VFP Posted by Anders Altberg @ 12/23/2009 12:31:54 PM
RE: call Excel from VFP Posted by Stefan Wuebbe @ 12/23/2009 4:12:52 PM
RE: call Excel from VFP Posted by M. Akram Bhatti @ 12/23/2009 12:00:10 PM
RE: call Excel from VFP Posted by Stefan Wuebbe @ 12/23/2009 12:05:21 PM
RE: call Excel from VFP Posted by Riccardo Pimpini @ 12/23/2009 12:18:24 PM
RE: call Excel from VFP Posted by tushar @ 12/23/2009 1:11:17 PM
RE: call Excel from VFP Posted by Riccardo Pimpini @ 12/23/2009 2:08:23 PM
RE: call Excel from VFP Posted by tushar @ 12/23/2009 3:27:06 PM
RE: call Excel from VFP Posted by Stefan Wuebbe @ 12/23/2009 4:18:01 PM
RE: call Excel from VFP Posted by Stefan Wuebbe @ 12/23/2009 4:43:31 PM
RE: call Excel from VFP Posted by Cetin Basoz @ 12/23/2009 3:40:39 PM