0
votes

I've got list of SQL commands in an excel sheet. Similar to this:

update table1 set data =100 where point=123
update table1 set data =100 where point=421
update table1 set data =100 where point=12333
update table1 set data =100 where point=90

'4'

Where 4 represents count of commands. What I need with them is export into .sql file and save. I've found a great tutorial which helped me a lot but at the end ot it there was a line saying not to worry about double quotes.
Well I do.
My code looks like this:

Sub OpenTextFile()

Dim FilePath As String
Dim LastRow As Long
Dim CellData As String

FilePath = ThisWorkbook.Path & "\" & "update.sql"
LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row

Open FilePath For Output As #1
For i = 1 To LastRow
CellData = ActiveCell(i).Value
Write #1, CellData
Next i
Close #1

End Sub

And exports data but I can't find a way to get rid of these quotes beacouse output looks like:

"update table1 set data =100 where point=123"

And so on.

1

1 Answers

1
votes

Change Write #1, CellData to Print #1, CellData

That worked for me in my tests. Further reading here: https://msdn.microsoft.com/en-us/library/office/gg264278.aspx