I apologizes but it was dinner time 
Here is the script :
on run
local lesFichiersExcel, theFolder, ext, theName, thePathname, openFile, uneSource, i
# I inserted the type identifier "public.comma-separated-values-text" because it's the one wore by the csv generated by the export scripts.
set lesFichiersExcel to choose file with prompt "Select the files to merge" of type {"org.openxmlformats.spreadsheetml.sheet", "com.microsoft.excel.xls", "com.apple.traditional-mac-plain-text", "public.comma-separated-values-text"} with multiple selections allowed
# Extract the container, the name, the name extension of the first item in the list of selected ones
tell application "System Events" to tell disk item (item 1 of lesFichiersExcel as text)
set {theFolder, theName, ext} to {path of container, name, name extension}
end tell
set theName to (text 1 thru -(1 + (length of ext)) of theName) & "csv"
# Define the name of the merged file
display dialog "Define the merged file name" default answer theName
set theName to text returned of result
if theName does not end with ".csv" then set theName to theName & ".csv"
# Select the folder in which the merged file will be saved
choose folder with prompt "Location of the merged file" default location (theFolder as alias)
# Build the pathname of the merged file
set thePathname to (result as text) & theName
tell current application to set openFile to open for access file thePathname with write permission # EDITED
set eof openFile to 0
# Treats the first source file (we keep the first row)
set uneSource to item 1 of lesFichiersExcel
tell application "System Events" to tell disk item (uneSource as text)
type identifier
end tell
if result is in {"org.openxmlformats.spreadsheetml.sheet", "com.microsoft.excel.xls"} then
my treatAnExcelFile(uneSource, 1, openFile)
else
my treatACSVFile(uneSource, 1, openFile)
end if
# Treat the other source file(s) (we drop the first row)
repeat with i from 2 to count lesFichiersExcel
set uneSource to item i of lesFichiersExcel
tell application "System Events" to tell disk item (uneSource as text)
type identifier
end tell
if result is in {"org.openxmlformats.spreadsheetml.sheet", "com.microsoft.excel.xls"} then
my treatAnExcelFile(item i of lesFichiersExcel, 2, openFile)
else
my treatACSVFile(uneSource, 2, openFile)
end if
end repeat
tell current application to close access openFile # EDITED
end run
--=====
# CAUTION, I removed a parameter so that the call to the two handlers use the same syntax !
on treatAnExcelFile(a_Pathname, start_Row, open_File)
local delim, lastCol, lastRow, r, cellVal, rowStr, e, n, sep, errmsg
character 2 of (0.5 as text)
if result is "," then
set delim to ";"
# set sep1000 to character id 160
else
set delim to ","
# set sep1000 to ","
end if
tell application "Microsoft Excel"
activate
try
open a_Pathname
set lastCol to count of columns of used range of active sheet
set lastRow to count of rows of used range of active sheet
repeat with r from start_Row to lastRow
set cellVal to (value of cell r of column 1 of active sheet) as text
if cellVal contains delim then set cellVal to quote & cellVal & quote # ADDED
set rowStr to cellVal
repeat with c from 2 to lastCol
set cellVal to (value of cell r of column c of active sheet) as text
if cellVal contains delim then set cellVal to quote & cellVal & quote # ADDED
set rowStr to rowStr & delim & cellVal
end repeat
tell current application to write rowStr & return to open_File as «class utf8» # EDITED
end repeat
on error e number n
tell current application to close access open_File # EDITED
-- Chris Stone
set sep to "------------------------------------------"
set errmsg to sep & return & "Error: " & e & return & sep & return & "Error
Number: " & n & return & sep
tell application "SystemUIServer"
activate
display dialog errmsg
end tell
set fail to true
end try
close active workbook saving no
end tell
end treatAnExcelFile
--=====
on treatACSVFile(a_Pathname, start_Row, open_File)
local desLignes, rowStr, e, n, sep, errmsg
# EDITED
try
set desLignes to paragraphs start_Row thru -1 of (read a_Pathname as «class utf8»)
on error
set desLignes to paragraphs start_Row thru -1 of (read a_Pathname)
end try
try
repeat with rowStr in desLignes
write (rowStr as text) & return to open_File as «class utf8»
end repeat
on error e number n
tell current application to close access open_File # EDITED
-- Chris Stone
set sep to "------------------------------------------"
set errmsg to sep & return & "Error: " & e & return & sep & return & "Error
Number: " & n & return & sep
tell application "SystemUIServer"
activate
display dialog errmsg
end tell
set fail to true
end try
end treatACSVFile
I added a close access instruction in the handlers because leaving a file in openfor access state is weird.
As you see, I changed a lot of varnames because I was not at ease with some of them, mainly with outFile naming the container of the file.
I am accustomed to put an underscore in the name of parameters received by the handlers.
I hope that I forgot nothing.
Yvan KOENIG (VALLAURIS, France) samedi 8 septembre 2012 21:01:30