Triple Quotes when saving an excel file as csv VBA
I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World"
but I'm getting """Hello World"""
when I open the CSV file. the CSV is comma delimited
edit: if I save it without the quotes, its save like Hello world
Do While xExcelFile <> ""
newFileName = Replace(xExcelFile, " ", "_")
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs fileName:=xSPath & newFileName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
'workbooks transformed log into cells
Cells(cont, 6).Value = newFileName
cont = cont + 1
NextLoop:
'next file
xExcelFile = Dir
Loop
excel vba excel-vba quotes double-quotes
add a comment |
I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World"
but I'm getting """Hello World"""
when I open the CSV file. the CSV is comma delimited
edit: if I save it without the quotes, its save like Hello world
Do While xExcelFile <> ""
newFileName = Replace(xExcelFile, " ", "_")
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs fileName:=xSPath & newFileName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
'workbooks transformed log into cells
Cells(cont, 6).Value = newFileName
cont = cont + 1
NextLoop:
'next file
xExcelFile = Dir
Loop
excel vba excel-vba quotes double-quotes
3
If you need it to literally be"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.
– JNevill
Nov 23 '18 at 18:23
@BigBen if I save it without the quotes, its save likeHello world
– Jose Chiesa
Nov 23 '18 at 18:31
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25
add a comment |
I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World"
but I'm getting """Hello World"""
when I open the CSV file. the CSV is comma delimited
edit: if I save it without the quotes, its save like Hello world
Do While xExcelFile <> ""
newFileName = Replace(xExcelFile, " ", "_")
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs fileName:=xSPath & newFileName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
'workbooks transformed log into cells
Cells(cont, 6).Value = newFileName
cont = cont + 1
NextLoop:
'next file
xExcelFile = Dir
Loop
excel vba excel-vba quotes double-quotes
I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World"
but I'm getting """Hello World"""
when I open the CSV file. the CSV is comma delimited
edit: if I save it without the quotes, its save like Hello world
Do While xExcelFile <> ""
newFileName = Replace(xExcelFile, " ", "_")
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs fileName:=xSPath & newFileName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
'workbooks transformed log into cells
Cells(cont, 6).Value = newFileName
cont = cont + 1
NextLoop:
'next file
xExcelFile = Dir
Loop
excel vba excel-vba quotes double-quotes
excel vba excel-vba quotes double-quotes
edited Nov 23 '18 at 18:29
Jose Chiesa
asked Nov 23 '18 at 18:19
Jose ChiesaJose Chiesa
103
103
3
If you need it to literally be"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.
– JNevill
Nov 23 '18 at 18:23
@BigBen if I save it without the quotes, its save likeHello world
– Jose Chiesa
Nov 23 '18 at 18:31
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25
add a comment |
3
If you need it to literally be"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.
– JNevill
Nov 23 '18 at 18:23
@BigBen if I save it without the quotes, its save likeHello world
– Jose Chiesa
Nov 23 '18 at 18:31
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25
3
3
If you need it to literally be
"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.– JNevill
Nov 23 '18 at 18:23
If you need it to literally be
"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.– JNevill
Nov 23 '18 at 18:23
@BigBen if I save it without the quotes, its save like
Hello world
– Jose Chiesa
Nov 23 '18 at 18:31
@BigBen if I save it without the quotes, its save like
Hello world
– Jose Chiesa
Nov 23 '18 at 18:31
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25
add a comment |
2 Answers
2
active
oldest
votes
Try this
Sub test()
Dim xSpath As String
Dim newFileName As String
Dim rngDB As Range
xSpath = ThisWorkbook.Path & ""
newFileName = "test1"
Set rngDB = Range("a1").CurrentRegion
TransToCsv rngDB, XPath & newFileName & ".csv"
End Sub
Sub TransToCsv(rngDB As Range, strFile As String)
Dim vDB, vR() As String, vTxt()
Dim i As Long, j As Integer
Dim objStream
Dim strTxt As String
Set objStream = CreateObject("ADODB.Stream")
vDB = rngDB
For i = 1 To UBound(vDB, 1)
n = n + 1
ReDim vR(1 To UBound(vDB, 2))
For j = 1 To UBound(vDB, 2)
If IsNumeric(vDB(i, j)) Then
vR(j) = vDB(i, j)
Else
vR(j) = Chr(34) & vDB(i, j) & Chr(34)
End If
Next j
ReDim Preserve vTxt(1 To n)
vTxt(n) = Join(vR, ",")
Next i
strTxt = Join(vTxt, vbCrLf)
With objStream
'.Charset = "utf-8"
.Open
.WriteText strTxt
.SaveToFile strFile, 2
.Close
End With
Set objStream = Nothing
End Sub
Thanks it works now, i have a question, what does it means.SaveToFile strFile, 2
the "2" on this line ?
– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
add a comment |
Using this part of your code:
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "teststs" & ".csv", FileFormat:=xlCSV, CreateBackup:=False
My file saves fine with one set of double quotes as expected... so maybe the problem lies somewhere else within your code. What is the path you are saving to? Is it the same as the folder you are loading the excel files from?
Thinking you might be looping through the CSV's as well, hence the extra quotes...
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451389%2ftriple-quotes-when-saving-an-excel-file-as-csv-vba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this
Sub test()
Dim xSpath As String
Dim newFileName As String
Dim rngDB As Range
xSpath = ThisWorkbook.Path & ""
newFileName = "test1"
Set rngDB = Range("a1").CurrentRegion
TransToCsv rngDB, XPath & newFileName & ".csv"
End Sub
Sub TransToCsv(rngDB As Range, strFile As String)
Dim vDB, vR() As String, vTxt()
Dim i As Long, j As Integer
Dim objStream
Dim strTxt As String
Set objStream = CreateObject("ADODB.Stream")
vDB = rngDB
For i = 1 To UBound(vDB, 1)
n = n + 1
ReDim vR(1 To UBound(vDB, 2))
For j = 1 To UBound(vDB, 2)
If IsNumeric(vDB(i, j)) Then
vR(j) = vDB(i, j)
Else
vR(j) = Chr(34) & vDB(i, j) & Chr(34)
End If
Next j
ReDim Preserve vTxt(1 To n)
vTxt(n) = Join(vR, ",")
Next i
strTxt = Join(vTxt, vbCrLf)
With objStream
'.Charset = "utf-8"
.Open
.WriteText strTxt
.SaveToFile strFile, 2
.Close
End With
Set objStream = Nothing
End Sub
Thanks it works now, i have a question, what does it means.SaveToFile strFile, 2
the "2" on this line ?
– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
add a comment |
Try this
Sub test()
Dim xSpath As String
Dim newFileName As String
Dim rngDB As Range
xSpath = ThisWorkbook.Path & ""
newFileName = "test1"
Set rngDB = Range("a1").CurrentRegion
TransToCsv rngDB, XPath & newFileName & ".csv"
End Sub
Sub TransToCsv(rngDB As Range, strFile As String)
Dim vDB, vR() As String, vTxt()
Dim i As Long, j As Integer
Dim objStream
Dim strTxt As String
Set objStream = CreateObject("ADODB.Stream")
vDB = rngDB
For i = 1 To UBound(vDB, 1)
n = n + 1
ReDim vR(1 To UBound(vDB, 2))
For j = 1 To UBound(vDB, 2)
If IsNumeric(vDB(i, j)) Then
vR(j) = vDB(i, j)
Else
vR(j) = Chr(34) & vDB(i, j) & Chr(34)
End If
Next j
ReDim Preserve vTxt(1 To n)
vTxt(n) = Join(vR, ",")
Next i
strTxt = Join(vTxt, vbCrLf)
With objStream
'.Charset = "utf-8"
.Open
.WriteText strTxt
.SaveToFile strFile, 2
.Close
End With
Set objStream = Nothing
End Sub
Thanks it works now, i have a question, what does it means.SaveToFile strFile, 2
the "2" on this line ?
– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
add a comment |
Try this
Sub test()
Dim xSpath As String
Dim newFileName As String
Dim rngDB As Range
xSpath = ThisWorkbook.Path & ""
newFileName = "test1"
Set rngDB = Range("a1").CurrentRegion
TransToCsv rngDB, XPath & newFileName & ".csv"
End Sub
Sub TransToCsv(rngDB As Range, strFile As String)
Dim vDB, vR() As String, vTxt()
Dim i As Long, j As Integer
Dim objStream
Dim strTxt As String
Set objStream = CreateObject("ADODB.Stream")
vDB = rngDB
For i = 1 To UBound(vDB, 1)
n = n + 1
ReDim vR(1 To UBound(vDB, 2))
For j = 1 To UBound(vDB, 2)
If IsNumeric(vDB(i, j)) Then
vR(j) = vDB(i, j)
Else
vR(j) = Chr(34) & vDB(i, j) & Chr(34)
End If
Next j
ReDim Preserve vTxt(1 To n)
vTxt(n) = Join(vR, ",")
Next i
strTxt = Join(vTxt, vbCrLf)
With objStream
'.Charset = "utf-8"
.Open
.WriteText strTxt
.SaveToFile strFile, 2
.Close
End With
Set objStream = Nothing
End Sub
Try this
Sub test()
Dim xSpath As String
Dim newFileName As String
Dim rngDB As Range
xSpath = ThisWorkbook.Path & ""
newFileName = "test1"
Set rngDB = Range("a1").CurrentRegion
TransToCsv rngDB, XPath & newFileName & ".csv"
End Sub
Sub TransToCsv(rngDB As Range, strFile As String)
Dim vDB, vR() As String, vTxt()
Dim i As Long, j As Integer
Dim objStream
Dim strTxt As String
Set objStream = CreateObject("ADODB.Stream")
vDB = rngDB
For i = 1 To UBound(vDB, 1)
n = n + 1
ReDim vR(1 To UBound(vDB, 2))
For j = 1 To UBound(vDB, 2)
If IsNumeric(vDB(i, j)) Then
vR(j) = vDB(i, j)
Else
vR(j) = Chr(34) & vDB(i, j) & Chr(34)
End If
Next j
ReDim Preserve vTxt(1 To n)
vTxt(n) = Join(vR, ",")
Next i
strTxt = Join(vTxt, vbCrLf)
With objStream
'.Charset = "utf-8"
.Open
.WriteText strTxt
.SaveToFile strFile, 2
.Close
End With
Set objStream = Nothing
End Sub
answered Nov 23 '18 at 23:50
Dy.LeeDy.Lee
3,5671510
3,5671510
Thanks it works now, i have a question, what does it means.SaveToFile strFile, 2
the "2" on this line ?
– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
add a comment |
Thanks it works now, i have a question, what does it means.SaveToFile strFile, 2
the "2" on this line ?
– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
Thanks it works now, i have a question, what does it means
.SaveToFile strFile, 2
the "2" on this line ?– Jose Chiesa
Nov 26 '18 at 12:58
Thanks it works now, i have a question, what does it means
.SaveToFile strFile, 2
the "2" on this line ?– Jose Chiesa
Nov 26 '18 at 12:58
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
@JoseChiesa, adSaveCreateNotExist 1 Default. Creates a new file if the file specified by the FileName parameter does not already exist. // adSaveCreateOverWrite 2 Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists. If the file specified by the Filename parameter does not exist, a new file is created.
– Dy.Lee
Nov 26 '18 at 13:14
add a comment |
Using this part of your code:
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "teststs" & ".csv", FileFormat:=xlCSV, CreateBackup:=False
My file saves fine with one set of double quotes as expected... so maybe the problem lies somewhere else within your code. What is the path you are saving to? Is it the same as the folder you are loading the excel files from?
Thinking you might be looping through the CSV's as well, hence the extra quotes...
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
add a comment |
Using this part of your code:
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "teststs" & ".csv", FileFormat:=xlCSV, CreateBackup:=False
My file saves fine with one set of double quotes as expected... so maybe the problem lies somewhere else within your code. What is the path you are saving to? Is it the same as the folder you are loading the excel files from?
Thinking you might be looping through the CSV's as well, hence the extra quotes...
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
add a comment |
Using this part of your code:
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "teststs" & ".csv", FileFormat:=xlCSV, CreateBackup:=False
My file saves fine with one set of double quotes as expected... so maybe the problem lies somewhere else within your code. What is the path you are saving to? Is it the same as the folder you are loading the excel files from?
Thinking you might be looping through the CSV's as well, hence the extra quotes...
Using this part of your code:
'*****************************************************
For Each c In Range("A1").CurrentRegion
If Not IsNumeric(c.Value) Then
c.Value = Chr(34) & c.Value & Chr(34)
End If
Next c
'******************************************************
'Saving file as csv
SaveFile:
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "teststs" & ".csv", FileFormat:=xlCSV, CreateBackup:=False
My file saves fine with one set of double quotes as expected... so maybe the problem lies somewhere else within your code. What is the path you are saving to? Is it the same as the folder you are loading the excel files from?
Thinking you might be looping through the CSV's as well, hence the extra quotes...
answered Nov 23 '18 at 20:48
DarXydeDarXyde
24016
24016
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
add a comment |
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
HI @DarXyde thanks for your answer, the loop only searches xls/xlsx files, and the csv file is saved in the same path as the excel files
– Jose Chiesa
Nov 23 '18 at 21:11
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
I don't see nothing in your DIR that stops the while loop to go through CSV files too, just saying. Try changing your save path to a different folder and see if there is a difference.
– DarXyde
Nov 24 '18 at 7:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451389%2ftriple-quotes-when-saving-an-excel-file-as-csv-vba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
If you need it to literally be
"Hello World"
with ONE double quote around each end of the word, then excel will escape those single double quotes with another double quote, as the double quote is the string encapsulation character that excel uses when writing as a "CSV" format. If your string that you are saving to CSV has a comma or a double quote in it, it will gain double quote string encapsulation and that string encapsulation character will be escaped.– JNevill
Nov 23 '18 at 18:23
@BigBen if I save it without the quotes, its save like
Hello world
– Jose Chiesa
Nov 23 '18 at 18:31
I think your misusing the Dir function, because the loop obviously ran 3 times so you have triple quotes. Let us see the whole code to fix this.
– VBasic2008
Nov 23 '18 at 22:25