I have the following problem: To save the Worksheet in a .txt file, I wrote this sub:
Sub SaveFile()
Dim ans As Long
Dim sSaveAsFilePath As String
Dim VPname As String
VPname = Worksheets(3).Cells(2, 1)
On Error GoTo ErrHandler:
sSaveAsFilePath = ActiveWorkbook.Path & "\" & VPname & ".txt"
If Dir(sSaveAsFilePath) <> "" Then
ans = MsgBox("Datei " & sSaveAsFilePath & " existiert bereits. Überschreiben?", vbYesNo + vbExclamation)
If ans <> vbYes Then
Exit Sub
Else
Kill sSaveAsFilePath
End If
End If
Worksheets(3).Copy '//Copy sheet 3 to new workbook
ActiveWorkbook.SaveAs sSaveAsFilePath, xlTextWindows '//Save as text (tab delimited) file
If ActiveWorkbook.name <> ThisWorkbook.name Then '//Double sure we don't close this workbook
ActiveWorkbook.Close False
End If
MsgBox ("Worksheet wurde erfolgreich als txt-Datei gespeichert!")
My_Exit:
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume My_Exit
End Sub
In this worksheet, the cells with text content have to have quotation marks (e.g. "example"). When I open the .txt-file, all these entrys have three quotation marks instead of one ("""example"""). Do you know how to fix this? Thanks a lot :)