Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I save .xls as .txt and not have "" around each line?

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I am trying to copy a range of cells into a text document. The code below copies the range, pastes it into the text document, saves the text document and then closes it. Everything works correctly except when I go to open the text document each line of text has quotes around it. In trying to solve the problem I entered text into column A and saved the file as .txt to see if there would be quotes around the text, and there were not. This leads me to believe it has something to do with the copying and/or pasting of the information. Does anybody know what adjustments I could make to not have the quotes around each line? Thanks in advance. -Matt


Public Sub SaveScriptsToTXT()

Dim Path As String
Dim FileName As String

'set path and file name variables
Path = Workbooks("Phoenix Security Form with VBA.xls").Sheets("Main").Range("J8").Value
FileName = Workbooks("Phoenix Security Form with VBA.xls").Sheets("Main").Range("J10").Value

'check to make sure path ends with a If Right(Path, 1) <> "\" Then
Path = Path & "\"
End If

'open the file that information is going to be saved to
Workbooks.OpenText FileName:=Path & FileName, _
DataType:=xlDelimited, Tab:=True

'find the range of cells in column A that have text
LastRow = Workbooks("Phoenix Security Form with VBA.xls").Sheets("Scripts").Range("a65536").End(xlUp).Row
TextRange = "A1:A" & LastRow

'select and copy the range of cells in column A
Workbooks("Phoenix Security Form with VBA.xls").Worksheets("Scripts").Activate
Workbooks("Phoenix Security Form with VBA.xls").Worksheets("Scripts").Range(TextRange).Select
Selection.Copy

Windows(FileName).Activate
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub
 
Hi,

SaveAs a .prn file.

Be sure to AutoFit all columns before you saveas so that you do not loose data.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Skip, thanks for the response. I saved the file as a .prn file but when I opened the file with notepad, each line still had quotes around it. Is there another file type or method that might work? Thanks in advance. -Matt
 
I don't know why. I just saved a worksheet as a .prn with both text and numeric values with NOT ONE quote.

Did you select the Save As Type,

Formatted Text (Space Delimited)(*.prn)

in the SaveAs dialog???

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Ok it worked now. Sorry about that, I dont know what I did wrong the first time. Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top