Hi everyone,
I am outputting the contents of a recordset to a text file. This file is later used by another program to import this text. However, everytime I output the text, each recordset field that I output has double quotes("") around them. This messes up the tags that I am outputting rendering this text unreadable by the importing program. Can someone please help me eliminate these double quotes. I have pasted my code below in case it helps.
Also, once I output to this text file, I would like to rename this file (change the extension from .txt to .xtg) using code. Right now I have users doing this manually. Does this sound possible?
Thanks,
ND
With rs
Dim stringToWrite As String
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
If .RecordCount > 0 Then
Set cdlg = New clsOpenSave
With cdlg
.Filter = "Text Files (*.txt)|*.txt"
.CancelError = True
.DialogTitle = "Save Output Files ..."
.InitDir = DIR_APP
.ShowSave
destFile = Replace(.FileName, vbNullChar, "")
destSave = Replace(.FileTitle, vbNullChar, "")
End With
Open destFile For Output As #1
For i = 0 To .RecordCount - 1
If .Fields(0) = currentCat Then
stringToWrite = .Fields(1)
Write #1, stringToWrite
Else
stringToWrite = .Fields(0)
Write #1, stringToWrite
currentCat = .Fields(0)
stringToWrite = .Fields(1)
Write #1, stringToWrite
End If
.MoveNext
Next
Close #1
End If
End If
.Close
End With
I am outputting the contents of a recordset to a text file. This file is later used by another program to import this text. However, everytime I output the text, each recordset field that I output has double quotes("") around them. This messes up the tags that I am outputting rendering this text unreadable by the importing program. Can someone please help me eliminate these double quotes. I have pasted my code below in case it helps.
Also, once I output to this text file, I would like to rename this file (change the extension from .txt to .xtg) using code. Right now I have users doing this manually. Does this sound possible?
Thanks,
ND
With rs
Dim stringToWrite As String
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
If .RecordCount > 0 Then
Set cdlg = New clsOpenSave
With cdlg
.Filter = "Text Files (*.txt)|*.txt"
.CancelError = True
.DialogTitle = "Save Output Files ..."
.InitDir = DIR_APP
.ShowSave
destFile = Replace(.FileName, vbNullChar, "")
destSave = Replace(.FileTitle, vbNullChar, "")
End With
Open destFile For Output As #1
For i = 0 To .RecordCount - 1
If .Fields(0) = currentCat Then
stringToWrite = .Fields(1)
Write #1, stringToWrite
Else
stringToWrite = .Fields(0)
Write #1, stringToWrite
currentCat = .Fields(0)
stringToWrite = .Fields(1)
Write #1, stringToWrite
End If
.MoveNext
Next
Close #1
End If
End If
.Close
End With