getting rid of commas in a vbs script

Hello,
this is a follow-up of a question posted to:
https://www.experts-exchange.com/questions/29066306/xlsx-xls-csv-conversion.html
here Bill Prew gave me an useful solution in this vbs script:

Const xlCSV = 6
Const xlTex = -4158
Const xlTextWindows = 20
Const msoEncodingUTF8 = 65001

strDir = "C:\Perl64\eg\alma"

Set objFSO = CreateObject("Scripting.FileSystemObject")

With CreateObject("Excel.Application")
    .Visible = False
    .DisplayAlerts = False

    For Each objFile In objFSO.GetFolder(strDir).Files
        strExt = objFSO.GetExtensionName(objFile.Path)
        If LCase(Left(strExt, 3)) = "xls" Then
            Wscript.Echo "Reading file: [" & objFile.Path & "]"
            With .Workbooks.Open(objFile.Path, False, True)
                With .Sheets(1)
                    .Rows(1).Delete
                    .Columns(1).Delete
                End With
                strPath = Replace(objFile.Path, "." & strExt, ".csv")
                Wscript.Echo "Writing file: [" & strPath & "]"
                .WebOptions.Encoding = msoEncodingUTF8
                .SaveAs strPath, xlTextWindows
                .Close False
            End With
        End If
    Next

    .Quit
End With

Set objFSO = Nothing

Open in new window

As the final csv is tab-delimited, I've discovered that the output of the script is wrapped with "" when there're commas in the content of some fields.
(say a content like a,B is rendered as "a,B")
As these commas are not important for me, is it possible integrating the script with a "find/relpace" that substitutes a space to the commas before all the other operations?
Thanks,
Fabiano
fabiano petroneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Try this small adjustment.

Const xlCSV = 6
Const xlTex = -4158
Const xlTextWindows = 20
Const msoEncodingUTF8 = 65001

strDir = "C:\Perl64\eg\alma"

Set objFSO = CreateObject("Scripting.FileSystemObject")

With CreateObject("Excel.Application")
    .Visible = False
    .DisplayAlerts = False

    For Each objFile In objFSO.GetFolder(strDir).Files
        strExt = objFSO.GetExtensionName(objFile.Path)
        If LCase(Left(strExt, 3)) = "xls" Then
            Wscript.Echo "Reading file: [" & objFile.Path & "]"
            With .Workbooks.Open(objFile.Path, False, True)
                With .Sheets(1)
                    .Rows(1).Delete
                    .Columns(1).Delete
                    .UsedRange.Replace What:=",", Replacement:=" ", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
                End With
                strPath = Replace(objFile.Path, "." & strExt, ".csv")
                Wscript.Echo "Writing file: [" & strPath & "]"
                .WebOptions.Encoding = msoEncodingUTF8
                .SaveAs strPath, xlTextWindows
                .Close False
            End With
        End If
    Next

    .Quit
End With

Set objFSO = Nothing

Open in new window


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fabiano petroneAuthor Commented:
Hi, Bill
I've an error on line 22 (the new one).
In italian: "prevista istruzione" (I guess something like "instruction expected") the Codex is 800A0400
Thanks,
Fabiano
Bill PrewIT / Software Engineering ConsultantCommented:
Oh, sorry, I gave you a VBA version but this is a VBS script, right?

If so I will need to adjust that just a bit...


»bp
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

fabiano petroneAuthor Commented:
yes: vbs
thanks,
Fabiano
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, please try this.

Const xlCSV = 6
Const xlTex = -4158
Const xlTextWindows = 20
Const xlPart = 2
Const xlWhole = 1
Const xlByColumns = 2
Const xlByRows = 1
Const msoEncodingUTF8 = 65001

strDir = "C:\Perl64\eg\alma"

Set objFSO = CreateObject("Scripting.FileSystemObject")

With CreateObject("Excel.Application")
    .Visible = False
    .DisplayAlerts = False

    For Each objFile In objFSO.GetFolder(strDir).Files
        strExt = objFSO.GetExtensionName(objFile.Path)
        If LCase(Left(strExt, 3)) = "xls" Then
            Wscript.Echo "Reading file: [" & objFile.Path & "]"
            With .Workbooks.Open(objFile.Path, False, True)
                With .Sheets(1)
                    .Rows(1).Delete
                    .Columns(1).Delete
                    .UsedRange.Replace ",", " ", xlPart, xlByRows, False, False, False
                End With
                strPath = Replace(objFile.Path, "." & strExt, ".csv")
                Wscript.Echo "Writing file: [" & strPath & "]"
                .WebOptions.Encoding = msoEncodingUTF8
                .SaveAs strPath, xlTextWindows
                .Close False
            End With
        End If
    Next

    .Quit
End With

Set objFSO = Nothing

Open in new window


»bp
fabiano petroneAuthor Commented:
Thanks a lot...it works!!
Bye
Fabiano
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.