# Converting Excel Data to Text

**URL:** <https://boards.straightdope.com/t/converting-excel-data-to-text/112252>\
**Category:** Factual Questions\
**Created:** [June 3, 2002, 10:56pm UTC](https://boards.straightdope.com/t/converting-excel-data-to-text/112252 "2002-06-03T22:56:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Earthling](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Earthling](https://boards.straightdope.com/u/Earthling)\
**Post date:** [June 3, 2002, 10:56pm UTC](https://boards.straightdope.com/t/converting-excel-data-to-text/112252/1 "2002-06-03T22:56:13Z")

</div>

I have a need to convert a whole pile of Excel files into text, and will be doing this regularly. Is there a way to automate this process, either through an external program, or an Excel macro/script? As it is, I know nothing about Excel programming, but I am _not_ looking forward to endless sessions of opening files and saving them as text individually. Thanks.

---

<div class="post-metadata">

**Author:** ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)\
**Post date:** [June 4, 2002, 1:30am UTC](https://boards.straightdope.com/t/converting-excel-data-to-text/112252/2 "2002-06-04T01:30:40Z")

</div>

Here a (kinda rough) macro:

```auto

Sub ConvertFiles()

FolderName = InputBox("Enter the folder name")
On Error GoTo BadFolder
ChDir (FolderName)
On Error GoTo 0
Set fs = Application.FileSearch
With fs
    .LookIn = FolderName
    .Filename = "*.xls"
    If .Execute(SortBy:=msoSortByFileName, _
            SortOrder:=msoSortOrderAscending) > 0 Then
        MsgBox "There were " & .FoundFiles.Count & _
            " file(s) found."
        For I = 1 To .FoundFiles.Count
            Workbooks.Open Filename:=.FoundFiles(I)
            NewFN = Left(.FoundFiles(I), InStr(.FoundFiles(I), ".") - 1) & ".txt"
            ActiveWorkbook.SaveAs Filename:=NewFN, FileFormat:=xlTextWindows
            ActiveWorkbook.Close savechanges:=False
        Next I
    Else
        MsgBox "There were no Excel files found in " & FolderName
    End If
End With
Exit Sub

BadFolder:
MsgBox "Folder does not exist!"

End Sub

```

---

<div class="post-metadata">

**Author:** ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)\
**Post date:** [June 4, 2002, 1:33am UTC](https://boards.straightdope.com/t/converting-excel-data-to-text/112252/3 "2002-06-04T01:33:15Z")

</div>

ps - There will be a bit of a complication if the workbooks contain multiple sheets… this macro only saves the first sheet.

---

<div class="post-metadata">

**Author:** ![Earthling](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Earthling](https://boards.straightdope.com/u/Earthling)\
**Post date:** [June 4, 2002, 7:51pm UTC](https://boards.straightdope.com/t/converting-excel-data-to-text/112252/4 "2002-06-04T19:51:38Z")

</div>

That works great! No trouble with multiple sheets – everything I need to export are on the first sheet. Now I need to tweak it slightly to move stuff to the right directories, but this is such a _huge_ improvement already. I’m sure I can figure the rest out & not trouble you any further.

Thank you! Thank you! Thank you!

🙂 & 🆒
