Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: saving selection as text file

  1. #11
    New Member
    Join Date
    Nov 2017
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: saving selection as text file

    Fluff,
    I am indebted to you for solving my excel problem. You truly have a mastered skill with this. The macro now works great. Thank you again for your assistance.

    ,jaystub

  2. #12
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    22,917
    Post Thanks / Like
    Mentioned
    385 Post(s)
    Tagged
    41 Thread(s)

    Default Re: saving selection as text file

    Glad to help & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  3. #13
    New Member
    Join Date
    Feb 2018
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: saving selection as text file

    Hi,

    i tried the code and it works great. i have 0 knowledge of the VB code, however i was wondering how can we modify this code to save the selected range in a Pipe separated format instead of Tab, along with a save-as option.

    Thanks and Regards,Sajjad Baig

  4. #14
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    22,917
    Post Thanks / Like
    Mentioned
    385 Post(s)
    Tagged
    41 Thread(s)

    Default Re: saving selection as text file

    Hi & welcome to the board.
    Have a look here
    http://www.cpearson.com/excel/imptext.aspx
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  5. #15
    Board Regular
    Join Date
    Mar 2009
    Posts
    187
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: saving selection as text file

    Try this
    Code:
    Public Sub ToText()
     Dim fso As Object
     Set fso = CreateObject("Scripting.FileSystemObject")
     Dim Fileout As Object
     Dim Ext As String 'Extension
     On Error Resume Next
     Path = CreateObject("WScript.Shell").SpecialFolders("Desktop")
     Ext = "txt" '   Ext="cnc" or  Ext= "csv"
     Set Fileout = fso.CreateTextFile(ThisWorkbook.Path & "\vba.Ext", True, True)
     Set Fileout = fso.CreateTextFile(Path & "\vba.txt", True, True)
      On Error GoTo 0
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Set MyRange = Range("A3:H5") 'Select Your Range'
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
             Fileout.Write "Good Day All" & vbNewLine
             Fileout.Write "What you want to say" & vbNewLine
            For Each Rng In MyRange
                Fileout.Write Rng.Value & vbNewLine
            Next
             Fileout.Write "end of message" & vbNewLine
             Fileout.Write "Thank" & vbNewLine
    
    
        Fileout.Close
        Shell "Notepad " & ThisWorkbook.Path & "\vba.txt", vbMaximizedFocus
    End Sub
    Last edited by Dossfm0q; Feb 25th, 2018 at 09:46 AM.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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