Link to home
Start Free TrialLog in
Avatar of Sat Nuna
Sat Nuna

asked on

open csv file as excel by using command prompt

I have to open csv file after creating from Powerbuilder.
Upon creating csv file , I have to open csv file as excel file automatically.

So I think it is better to use command prompt.
How could I open csv file as excel by using command prompt?
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try something like

"c:\program files\microsoft office\office12\excel.exe" "c:\newfile.csv" 

Open in new window

Adjust the path of Excel accordingly

Regards
if i have a file called examples.csv in a folder called downloads on my E: drive - so the path to the file is e:\downloads\examples.csv.   I simply need to call excel.exe and provide the filename path at  the end

so, assuming  that the PATH variable does not already include the path to the Excel exe file, I would need to put in "c:\program files (x86)\microsoft office\office15\excel.exe" to launch Excel (2013)

to launch excel and open the CSV file, I would simply type this command (you need the quotations because of the spaces in the folder path)

"c:\program files (x86)\Microsoft Office\Office15\Excel.exe" e:\downloads\examples.csv
Avatar of Sat Nuna

ASKER

The path written for location at installed excel seems it depends on where you installed office and what version installed.
So I think if I use this command, I should have located the installed path before.
Can't I use other way or can I locate the path simply by using command prompt or powerbuilder?
you could use additional commands to find the excel.exe file, and then build that into the path - however that is a bit more complex.


much easier to accomplish in VBS

strComputer="."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = TRUE
Set objWorkbook = objExcel.Workbooks.Open("e:\downloads\examples.csv")

Open in new window

Than you for your help.
It worked!
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Than you for your solution.
It rather simple than vbs and worlk any pc.
Yes your solution is best . But I don't know how to change accepted comment.
thanks