Excel Text Export: Commas creating unwanted Inverted Commas

pricer

New Member
Joined
Mar 21, 2007
Messages
25
I am trying to generate .sql scripts to drive a DTS package, I am using Excel as the hub as certain elements within the script change on a weekly basis. So I am the stage where I want to export my worksheet into .txt/.sql format. However, when I use the FileFormat:=xlText export function, the exported text file includes inverted commas around code which has commas.

Is there a way I can export an excel worksheet into a .txt/.sql compatible format which includes commas which doesn't include inverted commas?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
the exported text file includes inverted commas around code which has commas.
I think you are talking about single quotes (not inverted commas). These are often used as Text Qualifiers in SQL, csv text files, etc.

Can you post the relevant section of code, and a small sample of your data so we can try to reproduce the behavior?
 
Upvote 0
I've since found a solution, it seems most people refer to inverted commas as "quotation marks" which threw my searches off a little - so in order to export excel cells to text without quotation marks here is the code:

Sub Export()
Dim r As Range, c As Range
Dim sTemp As String

Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c

'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1
End Sub
 
Upvote 0
it seems most people refer to inverted commas as "quotation marks" which threw my searches off a little
I have actually never heard anyone refer to them as "inverted commas". Commas usually are on the bottom of a cell.

There are two types of quotation marks, single and double. SQL uses single quotation marks a lot.

Glad you got the issue sorted out.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top