save file as text

wwrightchess

New Member
Joined
Apr 20, 2022
Messages
29
Office Version
  1. 365
Platform
  1. MacOS
I am trying to take columns of data from a spreadsheet and save it as a text file.
Saving as an excel workbook works fine. I have tried other text formats and have the same problem.

Sub extract_shape()
'
' extract_shape Macro
'

'
Dim myPath As String
Dim myName As String
Dim fullname As String
Dim i As Long
Dim filelist() As Variant

myPath = "/Volumes/MyPassport/parameter_studies/roughness/roughness_cases/"
ReDim filelist(0)
filelist(0) = myPath
fileAccessGranted = GrantAccessToMultipleFiles(filelist)
For i = 5 To 5
Workbooks("large_and_glaze_adjusted_clean.xlsx").Activate
myName = Cells(i, 1)
fullname = myPath & myName & "LE.xls"
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Workbooks.Open filename:=fullname
Sheets("Ice Tracing").Select
lr = Cells(Rows.Count, 3).End(xlUp).Row
Range("C13:D" & lr).Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
fullname = myPath & myName & "_exp.xlsx"
ActiveWorkbook.SaveAs filename:= _
fullname _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
fullname = myName & "LE.xls"
Workbooks(fullname).Activate
Sheets("Ice Tracing Lew").Select
lr = Cells(Rows.Count, 3).End(xlUp).Row
Range("C13:D" & lr).Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs
Application.CutCopyMode = False
fullname = myPath & myName & "_lew.txt"
ActiveWorkbook.SaveAs filename:= _
fullname _
, FileFormat:=xlUnicodeText, CreateBackup:=False
ActiveWindow.Close
fullname = myPath & myName & "LE.xls"
Workbooks(fullname).Activate
ActiveWindow.Close
Next i
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top