View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ivan Raiminius Ivan Raiminius is offline
external usenet poster
 
Posts: 258
Default 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