+ Reply to Thread
Results 1 to 4 of 4

Export worksheet to txt format

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    San Francisco, USA
    MS-Off Ver
    Excel 365
    Posts
    34

    Export worksheet to txt format

    I am new to VBA/macro and trying to import and export txt data format.

    In this code/attached sample Excel file, I have successfully imported the text data into Excel and changed the data from text to column. But I cannot export to txt data format.

    After I change it to the column, I get a message box:

    "There's already data here. Do you want to replace it?" OK/Cancel

    Is there any way it can automatically click OK with the VBA code?

    After this I would like to save/export the 'Finalize' worksheet data to txt data file where the file name for the txt data should be the value of Worksheet 'Original' C3 and save the txt data into "C:\Users\Bishnu\Desktop\Work" directory.

    Please Login or Register  to view this content.
    Thank you in advance for your valuable suggestions/help.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Export worksheet to txt format

    If you are ready to accept that macro overwrites existing contents then you may disable displaying alerts before the command and reenable after, like:

    Please Login or Register  to view this content.
    The other option would be to clear the outbut range before you might use something like:
    Please Login or Register  to view this content.
    or similar
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-13-2014
    Location
    San Francisco, USA
    MS-Off Ver
    Excel 365
    Posts
    34

    Re: Export worksheet to txt format

    Thank you @Kaper. The alert message is disabled with this code.
    Any suggestion for exporting the 'finalize' worksheet data to txt data file, where the file name for the txt data should be the value of Worksheet 'Original' and cell C3 and save the txt data into "C:\Users\Bishnu\Desktop\Work" directory?

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Export worksheet to txt format

    try:
    Please Login or Register  to view this content.
    You may:
    - use a different fileformat parameter. A list of formats which could be used is here: https://learn.microsoft.com/en-us/of...l.xlfileformat
    - switch off before SaveAs displaying alerts if you want the new file overwriting previous version without warning and then on
    - switch off screenupdating before copy and switch back on after close which should reduce screen flickering

    Both DisplayAlerts and ScreenUpdating are properties of application object so could be used as
    Please Login or Register  to view this content.
    and so on

+ 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. [SOLVED] Import/Export Worksheet: Include Worksheet modules
    By Mingeita in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2023, 07:00 AM
  2. Export individual worksheet to CSV by pushing button on another worksheet
    By cworthington04 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2019, 04:25 PM
  3. Replies: 0
    Last Post: 02-01-2018, 04:52 PM
  4. Copy a range to other worksheet & Export to pdf format
    By mambo84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2013, 04:11 AM
  5. Inconsistent CSV export format
    By RichardOKeefe in forum Excel General
    Replies: 6
    Last Post: 05-10-2006, 12:20 AM
  6. [SOLVED] Format of CSV File in export
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 09-08-2005, 03:05 PM
  7. [SOLVED] how do I export a worksheet as a fixed format ascii file
    By SVANATTA65 in forum Excel General
    Replies: 2
    Last Post: 06-16-2005, 07:05 PM

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