leading and trailing double quotes in text file

JoeMajestee

New Member
Joined
Jul 15, 2009
Messages
49
I am trying to create text files containing output like this:

Line-One
Line-Two\foo

My code generates the following output, with double-quotes. Make it stop!

"Line-One
Line-Two\foo"

VBA Code:
Sub CreateTextFiles()
Dim myfile As String, saveloc As String, mycell As Range, myrng As Range, mytext As String
    mytext = "Line-One" & vbCrLf & _
    "Line-Two\"
Set myrng = Selection
saveloc = "c:\test\"
For Each mycell In myrng
myfile = saveloc & mycell & ".txt"
Open myfile For Output As #1
Write #1, mytext & mycell
Close #1
Next mycell
MsgBox "Finished", vbOK, "TXT Creation tool"
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

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