Queste macro sono eseguite da uno script che si pesca il fil excel nella cartella e poi applica in sequenza la macro
##############################################################################
msgBox("Conversione avviata")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim excelApplication
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim CurrentDirectory
CurrentDirectory = fso.GetAbsolutePathName(".")
Set excelApplication = CreateObject("Excel.Application")
Set OutputExcel = excelApplication.Workbooks.Open(CurrentDirectory & "\Macro\Macro.xlsm")
Dim filename
Dim colFiles
objStartFolder = CurrentDirectory
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If Instr(ucase(objFile.Name), UCase(".XLS")) Then filename=objFile.Name
Next
MsgBox "Nome file analizzato: " & CurrentDirectory & "" & filename
OutputExcel.Worksheets(1).Cells(1,1) =CurrentDirectory & "" & filename
'msgBox(filename)
Set OutputExcel2 = excelApplication.Workbooks.Open(CurrentDirectory & "" & filename)
excelApplication.Visible = True
excelApplication.DisplayAlerts = False
'msgBox(filename)
excelApplication.Application.Run "'Macro.xlsm'!'Seleziona_sheet'"
'msgBox("Copia_sheet fatta")
excelApplication.Application.Run "'Macro.xlsm'!'Elimina_warning'"
'msgBox("Elimina_warning fatta")
excelApplication.Application.Run "'Macro.xlsm'!'Cancella_colonne'"
'msgBox("Cancella_colonne fatta")
excelApplication.Application.Run "'Macro.xlsm'!'Sostituire_a_capo_con_spazi_e_zero'"
'msgBox("Sostituire_a_capo_con_spazi_e_zero fatta")
excelApplication.Application.Run "'Macro.xlsm'!'Modifica_header'"
'msgBox("Modifica_header fatta")
excelApplication.Application.Run "'Macro.xlsm'!'Salva_File_csv'"
'msgBox("Salva_File_csv fatta")
excelApplication.Workbooks(1).Close
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(CurrentDirectory & "\MSTCLL16_SCARTI.TXT", ForReading)
'msgBox(CurrentDirectory & " lettura file")
strText = objFile.ReadAll
strNewText = mid(strText, 1, len(strText)-2)
objFile.Close
strNewText1 = strNewText
strNewText2 = Replace(strNewText1, ",", ";")
strNewText3 = Replace(strNewText2, ".", ",")
Set objFile = objFSO.CreateTextFile(CurrentDirectory & "\MSTCLL16_SCARTI.TXT", True)
'msgBox(CurrentDirectory & " lettura file")
objFile.WriteLine strNewText3
objFile.Close
msgBox("Conversione terminata")
##################################################
Ma a volte funziona , altre no