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
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