Reputation: 195
I have an Access database that pulls information from different sources and populates a .TXT file that is then imported into another application.
My issue is that my .TXT file has quotation marks in, and I need to just find all of these and replace them with nothing using VBA.
I have the following code to open the file and do a find and replace.
Dim objFSO
Const ForReading = 1
Const ForWriting = 2
Dim objTS 'define a TextStream object
Dim strContents As String
Dim fileSpec As String
fileSpec = Forms![frm_MAIN_MENU]![txt_MAIN_ORDER_LOCATION].Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(fileSpec, ForReading)
strContents = objTS.ReadAll
strContents = Replace(strContents, "", "")
objTS.Close
Set objTS = objFSO.OpenTextFile(fileSpec, ForWriting)
objTS.Write strContents
objTS.Close
End Sub
However, the quotation marks within the quotation marks is giving me a headache.
Upvotes: 1
Views: 846
Reputation: 24366
Try replacing
strContents = Replace(strContents, "", "")
with
strContents = Replace(strContents, """", "")
Upvotes: 3