save txt file

  • Thread starter Thread starter Domagoj Vulin
  • Start date Start date
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.
 
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])
 
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...
 
Back
Top