Open Excel file using Bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dukdpk
Posts: 13
Joined: 10 Mar 2011 03:27

Open Excel file using Bat file

#1 Post by dukdpk » 16 Mar 2011 23:05

Hi All

I have following bat file. I want to open some of the excel files. This task must go under Select a task title by giving echo 6) Sample Reports. when Select 6, then have to display list of Sample reports. Then user is able to give option to open for particular excel file. Path for each excel files are,
C:\Reports\Staff Names.xls
C:\Reports\Codes.xls
C:\Reports\responsible works.xls
C:\Reports\class.xls

It doesn't matter create individual bat files to open for excel file. but these bat file must be called within the following one.


echo off
Reports Menu
:home
cls
echo.
echo Select a task:
echo =============
echo.
echo 0) Report Definitions
echo 1) Run newr001.Bat
echo 2) Run newr002.Bat
echo 3) Run newr003.Bat
echo 4) Run newr004.Bat
echo 5) Exit
set /p web=Type option:
if "%web%"=="0" goto Report Definitions
if "%web%"=="1" Call newr001.Bat
if "%web%"=="2" Call newr002.Bat
if "%web%"=="3" Call newr003.Bat
if "%web%"=="4" Call newr004.Bat
if "%web%"=="5" exit
goto home

:Report Definitions
echo newr001 ............. Report of Staff Names
echo newr002 ............. Report of codes
echo newr003 ............. Report of responsible work
echo newr004 ............. Report of class
Pause
goto home


Thank You

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: Open Excel file using Bat file

#2 Post by scienceguru1.bat » 17 Mar 2011 13:42

i dont know if it works, but usually you can do:

Code: Select all

"(excel.exe)" "(file to open)"

sometimes it helps if add

Code: Select all

start

or

Code: Select all

start ""

to the beginning

i dont KNOW this, but having two words for the report defs, doesnt really work well with batch. something like "defs" would make a much better term. they wont know what term you are using anyway, since you used "@echo off" at the beginning.

Post Reply