Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoke Excel at the command prompt

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
1
18
GB
I would like to fire up Excel from within a Clipper application, and in the first instance I would like to see if I can fire up an Excel session from the MS-DOS prompt, or from a batch file.

I have optimistically tried these things at the command line :

Run Excel.exe
Start Excel.exe

But without success

Thanks very much. Andrew
 
Memory issues you may experience aside, the virtual dos window your clipper app is running in needs to know the path to the excel folder. Create an autoexec.nt file in your application folder and store a path statement in it. If you can start excel from the dos prompt the the run command in your clipper app should be able to launch it as well.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Thanks Lyndon

The excel program is stored in

C:\program files\Microsoft Office\Office11\excel.exe

I have tried putting that in the path (in the autoexec.nt file); Although this pathname will then show up (if you key in the DOS command SET), that pathname does not appear to be used by the command processor, probably because of the 8-character limitation on path names in DOS.

One can get round this, by trial and error, by specifying a pathname (on my machine) of C:\progra~1\micros~3\office11, although this would then be dependent on the way that DOS interprets the long filenames ona particular machine.

If anyone has been able to invoke Excel (and indeed Word) from the DOS prompt I would be grateful to be able to copy their method. (I am running Windows XP)

Thanks again.

 
I just launched excel for a dos prompt in windows 7, same should work in XP.

Then I created a created startapp.bat with these contents:

set path=C:\Program Files\Microsoft Office\Office12
myApp.exe
REM end of batch file


contents of myApp.prg:
run excel.exe
quit
*end of myApp.prg

I compiled w/ clipper 5.2
I LINKED W/ BLINKER 5.0 with no libs external called, however, I created and overlay - myApp.ovl

It launches excel just fine. I used the long file name convention in my path statement.


Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Andrew,

I've been thinking on this issue and some DVM (DOS Virtual Machine) stuff is starting to come back to me... It's been a long time!

1. In your system folder you should find autoexec.nt and config.nt. Of course these replace autoexec.bat and config.sys from pre-NT operating systems. To make permanent system changes modify these files and every DVM instance will then be affected.

2. To overwrite your path statement use my previous example. Any other DVM instances will unaffected as each instance runs the .nt files independently and maintains its own values.

3. To append to the system path, and not overwrite the system path, replace the set command as follows:

set path=%path%;C:\Program Files\Microsoft Office\Office12

hope this helps

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Thanks Lyndon for your patience.

Your recipe (of setting the path, then using the RUN command within my Clipper program, or indeed at the command prompt) works fine.

The reason that it did not work for me appears to be that I was running a session under 4DOS (probably 4DOS 402, I am that much in the past). And it seems that that starting a separate Excel session from a program running under 4DOS does not work properly. It certainly finds the file (I get an error message if I 'Run' a non-existent file). But thereafter Excel does not fire up, and the original program no longer responds to commands, and has to be terminated.

But you have solved my problem. Thanks. Andrew Mozley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top