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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open Excel from Aspect?

Status
Not open for further replies.

MosGerila

Technical User
Jun 26, 2002
7
0
0
CA
I was wondering if any of you guys can tell me how to open Excel from an Aspect script without hard-coding the path to Excel.exe in the argument to the run command. The script needs to run on several machines which do not necessarily have Excel in the same directory.
Thanks a lot.
 
I was able to write a script that had run "excel.exe" without any path information and Excel started successfully. This was due to the location of excel.exe being in my PATH environment variable. If your systems are configured this way (I'm almost positive that the Office install modified by PATH settings), then this should work for you.
 
Hello

This should get you started.

This Script Starts Excel:

proc main
string Appl = "c:\program files\Office 97\office\excel.exe"
run appl
endproc

This Script Start Excel and Brings up and Excel File:

proc main
string Appl = "c:\program files\Office 97\office\excel.exe " ;* SPACE after .EXE !
string sFile = "c:\Files\TESTFILE.xls"
string outp
strcat outp Appl ;* Add Appl to outp String
strcat outp sFile ;* Add sFile to outp String
;* outp is now Appl + sFile
run outp ;* Run the Command with File Name to Open
endproc

Hank
 
Thank you all for your input! But... it doesn't work :(

Knob, my PATH does not include MS-Office information (the Office installer does not add it), so the Aspect command 'run "excel.exe"' won't work. I cannot/will not add anything to the PATH to make my script work. It has to run on any Windows 9x or NT machine without having to mess with environment variables.

Hankm3, unfortunately I cannot hard-code the path to Excel in my script. It varies from machine to machine, and the script has to run on many machines over which I have no control. The only common thing among them is that they all have Excel installed and it can be started by clicking Start > Run > type "excel" and click OK. So the Windows Run command works, but not the Aspect "run". I only wish they implemented it in such a way that it emulates the Windows Start > Run box.

Any other ideas, guys?
 
Hello Again,

Try This. It starts Excel Without a PathName.

Proc Main
Run "Excel.exe"
Endproc

Hank
 
I'm afraid it doesn't work, Hank! Your code only works if the DOS PATH variable includes the path to excel.exe or if you start the script from the directory where excel.exe lives.

Obviously I tried this before posting the first time. The solution will not be an obvious one, I'm afraid.
 
I stand corrected... I tried 'run "excel.exe"' at home and it worked, no path provided. At home, I have Windows XP and Office 2000. At work, I have Windows NT 4 and Office 97 and the above command does nothing at all. Hmmm...
 
Hi,

I have no Access to an NT Machine so I can't help there. Maybe Knob will pick this up and have an NT Solution.

Sorry

Hank
 
What versions of Office are you using? I was able to use run "excel.exe" on my NT machine at work and Win98 machine at home (both running Office 2000). On my Win98 machine, the path that excel.exe was found in was not listed in the PATH environment variable.

Is the XLS file always in the same location? If so, you could use run "xyz.xls" instead, and that will launch the spreadsheet in Excel.

I'll keep playing with this and see if I can think of a better way to do this. If nothing else, you could use the dos command to redirect dir /s excel.exe to a text file, then parse that file for the location of the file. I'm betting there's an easier way to get this information (too bad ASPECT doesn't have any hooks to read information from the registry).
 
knob,
Thank you for your help.

At work, all machines have Excel 97 (as a part of Office 97), Windows NT 4.0 with SP6a and Procomm 4.7.

run "excel.exe" does not work on any of the four machines I tried.

Yes, the Excel file is always in the same place (on a network drive), but I tried run "P:\full\path\to\myfile.xls" and it still does not work.

dir/s excel.exe takes forever (at least 20 seconds) -- not acceptable.

Still working on it... doh...
 
I finally found a way to get it to work. I tested this with Procomm 4.7 and Excel 97, on Windows 95 and also NT 4.0:

proc OpenExcel
; To start Excel without a file name:
dos "start excel" HIDDEN

; To load a file into an already open Excel
; (if Excel is not running, it will be opened):
; dos "start somefile.xls" HIDDEN

; To open a file in a new instance of Excel:
; dos "start excel somefile.xls" HIDDEN
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top