+ Reply to Thread
Results 1 to 5 of 5

macro to export a range to a text file?

  1. #1

    macro to export a range to a text file?

    Greetings experts...

    Is it possible to export the contents of a specified range to a text
    file?

    The worksheet will be protected and the cells locked. The range to
    export will always be the same. The user will not select the range,
    the range should already be defined in the macro.

    The macro should not save the entire workbook or worksheet as a text
    file, nor should it export the entire workbook or worksheet to a text
    file, nor should it prompt the user for any input whatsoever.

    Simply the contents of range $A:$5: $B:$20 ----> text file. I searched
    and searched for a known solution, but could not find one, hence my
    post here.

    If a delimiter is required, a simple space or tab will suffice.

    Thanks kindly.

    (Please note: I reviewed the excellent work of Pearson, Patterson,
    Peo, Max, and others, but their examples are not quite what I need, and
    I'm unsure of how to modify their examples to fit my needs.)

    J


  2. #2

    Re: macro to export a range to a text file?

    I wrote:

    > Simply the contents of range $A:$5: $B:$20 ----> text file.


    Er, that should be $A$5:$B$20

    Pardon the syntax mistake.

    J


  3. #3
    Buster
    Guest

    RE: macro to export a range to a text file?

    I was unable to find a solution that would directly export a range, but I
    have a workaround you might try. Code the macro to insert a new worksheet
    and copy/paste-values the range to export to the new worksheet's A1. Export
    the new worksheet using FileFormat property xlTextWindows then delete the
    inserted worksheet. [I used xlTextWindows as does not the add quote marks
    like xlTextMSDOS.]

    It may not be graceful, but it does what you want.

    "[email protected]" wrote:

    > Greetings experts...
    >
    > Is it possible to export the contents of a specified range to a text
    > file?
    >
    > The worksheet will be protected and the cells locked. The range to
    > export will always be the same. The user will not select the range,
    > the range should already be defined in the macro.
    >
    > The macro should not save the entire workbook or worksheet as a text
    > file, nor should it export the entire workbook or worksheet to a text
    > file, nor should it prompt the user for any input whatsoever.
    >
    > Simply the contents of range $A:$5: $B:$20 ----> text file. I searched
    > and searched for a known solution, but could not find one, hence my
    > post here.
    >
    > If a delimiter is required, a simple space or tab will suffice.
    >
    > Thanks kindly.
    >
    > (Please note: I reviewed the excellent work of Pearson, Patterson,
    > Peo, Max, and others, but their examples are not quite what I need, and
    > I'm unsure of how to modify their examples to fit my needs.)
    >
    > J
    >
    >


  4. #4

    Re: macro to export a range to a text file?

    Hello,

    Have a look here:
    http://www.erlandsendata.no/english/...atextexportcsv

    HTH,
    Bernd


  5. #5
    Buster
    Guest

    RE: macro to export a range to a text file?

    Scratch the part about xlTextWindows, it does save using the quotes. Sorry.

    "Buster" wrote:

    > I was unable to find a solution that would directly export a range, but I
    > have a workaround you might try. Code the macro to insert a new worksheet
    > and copy/paste-values the range to export to the new worksheet's A1. Export
    > the new worksheet using FileFormat property xlTextWindows then delete the
    > inserted worksheet. [I used xlTextWindows as does not the add quote marks
    > like xlTextMSDOS.]
    >
    > It may not be graceful, but it does what you want.
    >
    > "[email protected]" wrote:
    >
    > > Greetings experts...
    > >
    > > Is it possible to export the contents of a specified range to a text
    > > file?
    > >
    > > The worksheet will be protected and the cells locked. The range to
    > > export will always be the same. The user will not select the range,
    > > the range should already be defined in the macro.
    > >
    > > The macro should not save the entire workbook or worksheet as a text
    > > file, nor should it export the entire workbook or worksheet to a text
    > > file, nor should it prompt the user for any input whatsoever.
    > >
    > > Simply the contents of range $A:$5: $B:$20 ----> text file. I searched
    > > and searched for a known solution, but could not find one, hence my
    > > post here.
    > >
    > > If a delimiter is required, a simple space or tab will suffice.
    > >
    > > Thanks kindly.
    > >
    > > (Please note: I reviewed the excellent work of Pearson, Patterson,
    > > Peo, Max, and others, but their examples are not quite what I need, and
    > > I'm unsure of how to modify their examples to fit my needs.)
    > >
    > > J
    > >
    > >


+ 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