Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Alla fine ce l'ho fatta...ch fatica, anche perché conosco pochissimo il VB ma tra prog ad oggetti e formule Excel sono riuscito a raggiungere una soluz soddisfacente...
certo penso non sia il massimo, ma fa il suo lavoro... certo se la potessi migliorare sarebbe piu' fico :)
Sub Rename()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim colFiles As Scripting.Files
Dim objfile As Scripting.File
Dim tsFile As Scripting.TextStream
Dim strT As String
Dim strT1 As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(ThisWorkbook.Path)
Set colFiles = objFolder.Files
For Each objfile In colFiles
i = i + 1
If objfile.Name Like "*.txt" Then
Set tsFile = objfile.OpenAsTextStream(ForReading, TristateUseDefault)
TryNextLine:
If tsFile.AtEndOfStream Then GoTo NextFile
strT = tsFile.ReadLine
If InStr(1, LCase(strT), "NomeAzienda") > 0 And InStr(1, LCase(strT), "live") > 0 Then
tsFile.Close
'TextFile = objfile
'get the code name from the sting
strT1 = Trim(Left(strT, 10))
strT = Trim(Mid(strT, InStr(1, LCase(strT), "NomeAzienda") + 6, _
InStr(1, LCase(strT), "live") - InStr(1, LCase(strT), "NomeAzienda") - 6))
'lookup the new name from a table
strT1 = Application.VLookup(strT1, Worksheets("Codici").Range("A:B"), 2, False)
'lookup the new name from a table
strT = Application.VLookup(strT, Worksheets("Codici").Range("D:E"), 2, False)
'TextFile = FreeFile
'Open objfile For Input As TextFile
Name ThisWorkbook.Path & "" & objfile.Name As ThisWorkbook.Path & _
"" & (i - 1) & strT1 & strT & ".txt"
Else
GoTo TryNextLine
End If
End If
NextFile:
Next
'FileContent = Input(LOF(TextFile), TextFile)
'Report Out Text File Contents
MsgBox "Finito"
End Sub