+ Reply to Thread
Results 1 to 4 of 4

[Macro excel] How to create and export a sheet into a *.inp (or *.txt) file

  1. #1
    Registered User
    Join Date
    03-31-2006
    Posts
    4

    Question [Macro excel] How to create and export a sheet into a *.inp (or *.txt) file

    Hi

    I've got a little problem:
    I would like to create with a macro a *.txt file in a specific folder and copy the content of one the sheet on this *.txt file but I don't know how to proceed.
    In fact, I would be better for me to copy the content of this sheet in a *.inp file (that is a quite weird extension), but a *.txt file would be good enough.

    Thx for your help

  2. #2
    Mike Fogleman
    Guest

    Re: [Macro excel] How to create and export a sheet into a *.inp (or *.txt) file

    Something like this:

    Sub NewTextFile()
    Sheets("Sheet1").Copy
    ChDir "C:\" 'your folder path
    ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", FileFormat:=xlText, _
    CreateBackup:=False
    End Sub

    Mike F
    "MrKermit" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi
    >
    > I've got a little problem:
    > I would like to create with a macro a *.txt file in a specific folder
    > and copy the content of one the sheet on this *.txt file but I don't
    > know how to proceed.
    > In fact, I would be better for me to copy the content of this sheet in
    > a *.inp file (that is a quite weird extension), but a *.txt file would
    > be good enough.
    >
    > Thx for your help
    >
    >
    > --
    > MrKermit
    > ------------------------------------------------------------------------
    > MrKermit's Profile:
    > http://www.excelforum.com/member.php...o&userid=33021
    > View this thread: http://www.excelforum.com/showthread...hreadid=531464
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: [Macro excel] How to create and export a sheet into a *.inp (o

    You might want to add

    Sub NewTextFile()
    Sheets("Sheet1").Copy
    'ChDir "C:\" 'your folder path
    ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", _
    FileFormat:=xlText, _
    CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False
    End Sub

    You also don't need to chdir since the path is specified in the file name.
    If you did need to Chdir, you should also Chdrive as well.

    --
    Regards,
    Tom Ogilvy



    "Mike Fogleman" wrote:

    > Something like this:
    >
    > Sub NewTextFile()
    > Sheets("Sheet1").Copy
    > ChDir "C:\" 'your folder path
    > ActiveWorkbook.SaveAs Filename:="C:\Book2.txt", FileFormat:=xlText, _
    > CreateBackup:=False
    > End Sub
    >
    > Mike F
    > "MrKermit" <[email protected]> wrote in
    > message news:[email protected]...
    > >
    > > Hi
    > >
    > > I've got a little problem:
    > > I would like to create with a macro a *.txt file in a specific folder
    > > and copy the content of one the sheet on this *.txt file but I don't
    > > know how to proceed.
    > > In fact, I would be better for me to copy the content of this sheet in
    > > a *.inp file (that is a quite weird extension), but a *.txt file would
    > > be good enough.
    > >
    > > Thx for your help
    > >
    > >
    > > --
    > > MrKermit
    > > ------------------------------------------------------------------------
    > > MrKermit's Profile:
    > > http://www.excelforum.com/member.php...o&userid=33021
    > > View this thread: http://www.excelforum.com/showthread...hreadid=531464
    > >

    >
    >
    >


  4. #4
    Registered User
    Join Date
    03-31-2006
    Posts
    4
    Ok thanks, i'm gonna try

+ 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