save txt file

D

Domagoj Vulin

I'm VBA newbie and trying to save .txt file from Excel. The problem is that
it saves it in root of current active drive (in my case it is E:)
How can I get the folder where workbook is saved, something like
Server.MapPath in ASP?
Second problem - is it possible to run exe application from excel?
The point is that i have old fortran application, so I want to save input
data from excel to txt file, execute fortran application which saves the
output into output txt file and then, at last open from Excel macro that
output file and parse it to spreadsheet.
 
H

Hank Scorpio

I'm VBA newbie and trying to save .txt file from Excel. The problem is that
it saves it in root of current active drive (in my case it is E:)
How can I get the folder where workbook is saved, something like
Server.MapPath in ASP?

ActiveWorkbook.Path will give you the path of the active workbook.
However if the workbook hasn't been saved, it will return an empty
string.
Second problem - is it possible to run exe application from excel?
The point is that i have old fortran application, so I want to save input
data from excel to txt file, execute fortran application which saves the
output into output txt file and then, at last open from Excel macro that
output file and parse it to spreadsheet.

See on-line help for the Shell function, a summary of which is below:
--------------------------------
Shell Function

Runs an executable program and returns a Variant (Double) representing
the program's task ID if successful, otherwise it returns zero.

Syntax

Shell(pathname[,windowstyle])
 
D

Domagoj Vulin

Hank Scorpio said:
ActiveWorkbook.Path will give you the path of the active workbook.
However if the workbook hasn't been saved, it will return an empty
string.

Thanks, that's what I needed
Second problem - is it possible to run exe application from excel?
The point is that i have old fortran application, so I want to save input
data from excel to txt file, execute fortran application which saves the
output into output txt file and then, at last open from Excel macro that
output file and parse it to spreadsheet.

See on-line help for the Shell function, a summary of which is below:
--------------------------------
Shell Function

Runs an executable program and returns a Variant (Double) representing
the program's task ID if successful, otherwise it returns zero.

Syntax

Shell(pathname[,windowstyle])

Now I have to try this...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top