+ Reply to Thread
Results 1 to 9 of 9

Macro to save Excel as txt

  1. #1
    Registered User
    Join Date
    12-17-2019
    Location
    Odense, Denmark
    MS-Off Ver
    2019
    Posts
    4

    Macro to save Excel as txt

    Is it possible to make a macro that copy data from a Excel sheet to a txt-file?

    I need a macro that can copy to or save as txt, every time a save the Excel file, so it's always updated.
    Also it has to save the txt-file next to the Excel-file, so I'm able to move it or copy the Excel-file to a new location.


    I'll hope that someone can assist me?

    Thank you

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Macro to save Excel as txt

    Try like this:

    Into standard module:

    Please Login or Register  to view this content.
    into ThisWorkbook code:
    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Macro to save Excel as txt

    Something like the below, either to run as a macro or on , on an event
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-17-2019
    Location
    Odense, Denmark
    MS-Off Ver
    2019
    Posts
    4

    Re: Macro to save Excel as txt

    Thank you, it works perfectly!

    Just one more thing. Is it possible to divide the data with "Tab" and not comma?

  5. #5
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Macro to save Excel as txt

    try changing the file format
    FileFormat:=xlText

    does that make a difference?

  6. #6
    Registered User
    Join Date
    12-17-2019
    Location
    Odense, Denmark
    MS-Off Ver
    2019
    Posts
    4

    Re: Macro to save Excel as txt

    Attachment 654220

    It still not working, maybe the txt file format is wrong. I need it to save as Unicode text file (.txt)
    If i save it manually it works perfectly, but when I use the macro i got issues.
    I'm using the .txt in Autodesk Revit as a Keynote

    Please see my picture, the "Tab" it not the same, so I believe that it's what gives me problems?

  7. #7
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Macro to save Excel as txt

    Quote Originally Posted by Jakob CASA View Post
    Thank you, it works perfectly!

    Just one more thing. Is it possible to divide the data with "Tab" and not comma?
    In my code:


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-17-2019
    Location
    Odense, Denmark
    MS-Off Ver
    2019
    Posts
    4

    Re: Macro to save Excel as txt

    Quote Originally Posted by KOKOSEK View Post
    In my code:


    Please Login or Register  to view this content.
    That's perfect. It works now.

    Thank you

  9. #9
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Macro to save Excel as txt

    You welcome.
    Happy to help.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Macro - to move selected sheets no a new workbook and save, and save as pdf
    By manekankit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2019, 01:42 PM
  2. [SOLVED] macro button to save as macro excel template
    By chubbychub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2017, 06:19 PM
  3. [SOLVED] Macro-Launch Notepad from Excel and save data in notepad and save with naming conventio
    By hjaspaul in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-01-2016, 09:19 PM
  4. Macro to Save As for an Excel Macro Enabled workbook
    By hvitzthum in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2013, 09:19 AM
  5. Replies: 1
    Last Post: 07-26-2013, 11:05 PM
  6. [SOLVED] ASP: Open Excel File with Macro, Allow Macro to run, and then save
    By delgados129 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2005, 06:06 PM
  7. ASP: Open Excel File with Macro, Allow Macro to run, and then save
    By delgados in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2005, 05:14 PM

Tags for this Thread

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