Exporting Sheet as Txt File

natphil

New Member
Joined
Aug 27, 2015
Messages
3
Hi there,

I am attempting to export a worksheet as a text file using this code.

Sub RoundedRectangle2_Click()
ActiveSheet.SaveAs ThisWorkbook.Path & "\Purlinmacro3.spn", xlUnicodeText
End Sub

*I have tried multiple different file formats, including xlTextWindows, xlTextMSDOS, xlCSVWindows,xlCSV
I need the file to be in a .spn file, which is the exact same code as a text file. The macro successfully exports the file, in the correct format, however on each line there are quotation marks which render the file unreadable. Example.

I need the file to look like this (when opened with notepad)

"SupaZed"
"SZ15015","SZ15016","SZ15017","SZ15018","SZ15019","SZ15015","SZ15015","SZ15015","SZ15015","SZ15015","SZ15015","SZ15015"
"Single",0,0,5.85
4,8000,8000,8000,8000,0,7000,7000,7000,7000,7000,7000,7000,0,0
1,50,50,0,0
0,0,0,0,0
1,"%"
7.5,7.5

However, the file that is exported looks like this

"""SupaZed"""
"""SZ15015"",""SZ15016"",""SZ15017"",""SZ15018"",""SZ15019"",""SZ15015"",""SZ15015"",""SZ15015"",""SZ15015"",""SZ15015"",""SZ15015"",""SZ15015"""
"""Single"",0,0,5.85"
"4,8000,8000,8000,8000,0,7000,7000,7000,7000,7000,7000,7000,0,0"
"1,50,50,0,0"
"0,0,0,0,0"
"1,""%""
"7.5,7.5"

Could someone please suggest an alternative method that would solve this issue. Thankyou in advance.
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi ,
Please use xlTextPrinter format instead of xlUnicodeText however it will truncate the cell contents (I think more than 240 characters will be truncated).
If you are familiar with VBA please go with sub routine it will give you more flexibility.

Hope it helps!
 
Upvote 0

Forum statistics

Threads
1,214,902
Messages
6,122,161
Members
449,069
Latest member
msilva74

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