Results 1 to 6 of 6

convert all xlsx in directory to text using vb

Threaded View

cmccabe convert all xlsx in directory... 12-28-2015, 05:07 PM
JLGWhiz Re: convert all xlsx in... 12-28-2015, 05:14 PM
cmccabe Re: convert all xlsx in... 12-28-2015, 05:47 PM
JLGWhiz Re: convert all xlsx in... 12-28-2015, 07:32 PM
cmccabe Re: convert all xlsx in... 12-28-2015, 07:55 PM
JLGWhiz Re: convert all xlsx in... 12-28-2015, 09:52 PM
  1. #1
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    convert all xlsx in directory to text using vb

    I am trying to convert ~200 xlsx files in a directory to txt using vb. Is the below attempt close or what is the best way? Thank you .

    VB
    Sub convert()
        ChDir "C:\Users\cmccabe\Desktop\epilepsy"
        ActiveWorkbook.SaveAs Filename:= _
            "C:\Users\cmccabe\Desktop\epilepsy\*.txt", _
            FileFormat:=xlText, CreateBackup:=False
    End Sub
    or maybe:

    Sub Convert()
    Dim strPath As String
    Dim strFile As String
    Dim wbk As Workbook
    ' DEFINE LOCATION '
    strPath = "C:\Users\cmccabe\Desktop\epilepsy\xlsx\"
    strFile = Dir(strPath & "*.*")
    Do While strFile <> ""
    
    Set wbk = Workbooks.Open(FileName:=strPath & strFile)
    wbk.SaveAs FileName:=strPath & strFile, _
    FileFormat:=xlText
    wbk.Close SaveChanges:=True
    
    strFile = Dir
    Loop
    
    End Sub
    Last edited by cmccabe; 12-28-2015 at 05:12 PM. Reason: added code

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Save all xls files in directory as xlsx
    By StartRunMSPaint in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2014, 04:45 PM
  2. [SOLVED] convert xlsx to csv and save to file directory
    By shaz0503 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-27-2014, 07:19 PM
  3. how to convert .xlsx to .csv
    By Nehrav in forum Excel General
    Replies: 4
    Last Post: 11-04-2013, 07:24 AM
  4. [SOLVED] Won't convert xlsx to pdf well
    By sockerplaya37 in forum Excel General
    Replies: 2
    Last Post: 06-23-2013, 10:17 PM
  5. Convert xlsx to dat
    By swmmr1928 in forum Excel General
    Replies: 5
    Last Post: 03-13-2013, 05:30 PM
  6. Save all .xlsx files in a directory to .xls
    By paul00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2012, 08:05 PM
  7. Writing to all xlsx files in a directory
    By BretFelix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2010, 06:34 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