joe
joe

Reputation: 53

How to remove double quotation marks when converting from excel to text file?

Every time I use this code, for some reason, double quotation marks appear for cell's output from beginning to ending. Anyway how I can remove these quotation marks?

I tried using a basic VBA, where it copies data from a certain column and converts it to a txt file.

Dim s As String, FileName As String, FileNum As Integer

  ' Define full pathname of TXT file
  FileName = ThisWorkbook.Path & "\2019.con"

  ' Copy range to the clipboard
  Range("A2", Cells(Rows.Count, "A").End(xlUp)).Copy

  ' Copy column content to the 's' variable via clipboard
  With New DataObject
     .GetFromClipboard
     s = .GetText
  End With
  Application.CutCopyMode = False

  ' Write s to TXT file
  FileNum = FreeFile
  If Len(Dir(FileName)) > 0 Then Kill FileName
  Open FileName For Binary Access Write As FileNum
  Put FileNum, , s
  Close FileNum

Actual Result: "CONT=10" "." "." "."

Desired Result: CONT=10 . . .

Upvotes: 0

Views: 1312

Answers (1)

user11937721
user11937721

Reputation:

You should use Print not Write if you don't want the quote marks

Upvotes: 3

Related Questions