+ Reply to Thread
Results 1 to 6 of 6

Copy rows from excel sheet to a word document

  1. #1
    Registered User
    Join Date
    02-13-2006
    Posts
    46

    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

  2. #2
    Ivan Raiminius
    Guest

    Re: 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


  3. #3
    Registered User
    Join Date
    02-13-2006
    Posts
    46
    Not clear with referencing the Microsoft Scripting Runtime . how to do it.
    Thanks for the help.

  4. #4
    Ivan Raiminius
    Guest

    Re: Copy rows from excel sheet to a word document

    Hi Ashish,

    in VBA editor: Tools >> References check Microsoft Scripting Runtime

    Regards,
    Ivan


  5. #5
    Tom Ogilvy
    Guest

    RE: 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
    >
    >


  6. #6
    Registered User
    Join Date
    02-13-2006
    Posts
    46
    Thanks a lot. its working fine

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1