ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy rows from excel sheet to a word document (https://www.excelbanter.com/excel-programming/359926-copy-rows-excel-sheet-word-document.html)

ashishprem[_14_]

Copy rows from excel sheet to a word document
 

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


Ivan Raiminius

Copy rows from excel sheet to a word document
 
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


ashishprem[_15_]

Copy rows from excel sheet to a word document
 

Not clear with referencing the Microsoft Scripting Runtime . how to d
it.
Thanks for the help

--
ashishpre
-----------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...fo&userid=3148
View this thread: http://www.excelforum.com/showthread.php?threadid=53674


Ivan Raiminius

Copy rows from excel sheet to a word document
 
Hi Ashish,

in VBA editor: Tools References check Microsoft Scripting Runtime

Regards,
Ivan


Tom Ogilvy

Copy rows from excel sheet to a word document
 
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



ashishprem[_16_]

Copy rows from excel sheet to a word document
 

Thanks a lot. its working fine


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=536743



All times are GMT +1. The time now is 11:37 AM.

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