Hi,
I want to copy the records from excel sheets into a txt using macro? Is there any way to do the same?
Regards,
Ashish
Hi,
I want to copy the records from excel sheets into a txt using macro? Is there any way to do the same?
Regards,
Ashish
Hi Ashish,
yes, it is possible with code like this:
Sub WriteToTextFile
Dim fsFs As Scripting.FileSystemObject
Dim fsOutput As Scripting.TextStream
Dim OutputFile as String
OutputFile = ' here add path and filename, maybe also result of _
application.getsaveasfilename
Set fsFs = New FileSystemObject
Set fsOutput = fsFs.OpenTextFile(Filename:=OutputFile,
IOMode:=ForWriting, create:=True, Format:=TristateUseDefault)
fsOutput.writeline "here add what you want to write"
fsOutput.close
end sub
You need to set reference to Microsoft Scripting Runtime when trying to
run this code.
If anything is not clear, please let me know.
Regards,
Ivan
Not clear with referencing the Microsoft Scripting Runtime . how to do it.
Thanks for the help.
Hi Ashish,
in VBA editor: Tools >> References check Microsoft Scripting Runtime
Regards,
Ivan
You don't need the scripting runtime.
It could be as simple as
Thisworkbook.SavesAs "C:\Myfolder\Myfile.csv", xlCSV
or
http://www.cpearson.com/excel/imptext.htm import/export text files
as an example.
Of course the scripting runtime is a third option.
--
Regards,
Tom Ogilvy
"ashishprem" wrote:
>
> Hi,
> I want to copy the records from excel sheets into a txt using macro? Is
> there any way to do the same?
> Regards,
> Ashish
>
>
> --
> ashishprem
> ------------------------------------------------------------------------
> ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
> View this thread: http://www.excelforum.com/showthread...hreadid=536743
>
>
Thanks a lot. its working fine
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks