ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   [Macro excel] How to create and export a sheet into a *.inp (or *.txt) file (https://www.excelbanter.com/excel-programming/358474-%5Bmacro-excel%5D-how-create-export-sheet-into-%2A-inp-%2A-txt-file.html)

MrKermit[_3_]

[Macro excel] How to create and export a sheet into a *.inp (or *.txt) file
 

Hi

I've got a little problem:
I would like to create with a macro a *.txt file in a specific folde
and copy the content of one the sheet on this *.txt file but I don'
know how to proceed.
In fact, I would be better for me to copy the content of this sheet i
a *.inp file (that is a quite weird extension), but a *.txt file woul
be good enough.

Thx for your hel

--
MrKermi
-----------------------------------------------------------------------
MrKermit's Profile: http://www.excelforum.com/member.php...fo&userid=3302
View this thread: http://www.excelforum.com/showthread.php?threadid=53146


Mike Fogleman

[Macro excel] How to create and export a sheet into a *.inp (or *.txt) file
 
Something like this:

Sub NewTextFile()
Sheets("Sheet1").Copy
ChDir "C:\" 'your folder path
ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", FileFormat:=xlText, _
CreateBackup:=False
End Sub

Mike F
"MrKermit" wrote in
message ...

Hi

I've got a little problem:
I would like to create with a macro a *.txt file in a specific folder
and copy the content of one the sheet on this *.txt file but I don't
know how to proceed.
In fact, I would be better for me to copy the content of this sheet in
a *.inp file (that is a quite weird extension), but a *.txt file would
be good enough.

Thx for your help


--
MrKermit
------------------------------------------------------------------------
MrKermit's Profile:
http://www.excelforum.com/member.php...o&userid=33021
View this thread: http://www.excelforum.com/showthread...hreadid=531464




Tom Ogilvy

[Macro excel] How to create and export a sheet into a *.inp (o
 
You might want to add

Sub NewTextFile()
Sheets("Sheet1").Copy
'ChDir "C:\" 'your folder path
ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", _
FileFormat:=xlText, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False
End Sub

You also don't need to chdir since the path is specified in the file name.
If you did need to Chdir, you should also Chdrive as well.

--
Regards,
Tom Ogilvy



"Mike Fogleman" wrote:

Something like this:

Sub NewTextFile()
Sheets("Sheet1").Copy
ChDir "C:\" 'your folder path
ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", FileFormat:=xlText, _
CreateBackup:=False
End Sub

Mike F
"MrKermit" wrote in
message ...

Hi

I've got a little problem:
I would like to create with a macro a *.txt file in a specific folder
and copy the content of one the sheet on this *.txt file but I don't
know how to proceed.
In fact, I would be better for me to copy the content of this sheet in
a *.inp file (that is a quite weird extension), but a *.txt file would
be good enough.

Thx for your help


--
MrKermit
------------------------------------------------------------------------
MrKermit's Profile:
http://www.excelforum.com/member.php...o&userid=33021
View this thread: http://www.excelforum.com/showthread...hreadid=531464





MrKermit[_4_]

[Macro excel] How to create and export a sheet into a *.inp (or *.txt) file
 

Ok thanks, i'm gonna tr

--
MrKermi
-----------------------------------------------------------------------
MrKermit's Profile: http://www.excelforum.com/member.php...fo&userid=3302
View this thread: http://www.excelforum.com/showthread.php?threadid=53146



All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com