1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| Sub a_Mode_Diff_Single()
Dim myNames() As String
Dim fCtr As Long
Dim myFile As String
Dim myPath As String
Dim wks As Worksheet
Dim DestCell As Range
Dim RngToCopy As Range
Dim file As String
Dim foules As String
Dim Fichier As String, Chemin As String
Dim Wb As Workbook
Dim Mode As String
Dim SrcBook As Workbook
Dim fso As Object, f As Object, ff As Object, f1 As Object
Dim far As String
Dim Maximum As String
Dim Minimum As String
Dim Image As Variant
Dim choose As String
Application.ScreenUpdating = False
far = InputBox("...")
file = InputBox("...")
foules = InputBox("entrer dossier .xls \ à la fin:")
choose = InputBox("Nom du fichier à créer (créer dans le dossier des fichier .txt):")
myPath = file 'CONVERSION TXT ==> XLSX
If myPath = "" Then Exit Sub
If Right(myPath, 1) <> "\" Then
myPath = myPath & "\"
End If
myFile = ""
On Error Resume Next
myFile = Dir(myPath & "*.txt")
On Error GoTo 0
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If
Set DestCell = Workbooks.Add(1).Worksheets(1).Range("a1")
fCtr = 0
Do While myFile <> ""
fCtr = fCtr + 1
ReDim Preserve myNames(1 To fCtr)
myNames(fCtr) = myFile
myFile = Dir()
Loop
If fCtr > 0 Then
If fCtr > DestCell.Parent.Columns.Count Then
MsgBox "too many files!"
Exit Sub
End If
For fCtr = LBound(myNames) To UBound(myNames)
Application.StatusBar _
= "Processing: " & myNames(fCtr) & " at: " & Now
Workbooks.OpenText Filename:=myPath & myNames(fCtr), _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, _
Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), _
TrailingMinusNumbers:=True
Set wks = ActiveSheet 'TRAITEMENT FEUILLE
ActiveSheet.Select
ActiveSheet.Name = "1"
Range("G10:J10").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("G10:J10").Select
ActiveCell.FormulaR1C1 = "=MID(CELL(""filename""),SEARCH(""["",CELL(""filename""))+1, SEARCH(""]"",CELL(""filename""))-SEARCH(""["",CELL(""filename""))-5)" 'Formule nom du fichier ouvert
Next fCtr
End If
Application.DisplayAlerts = False
For Each classeur In Workbooks 'ENREGISTREMENT FICHIERS
If classeur.Name <> ThisWorkbook.Name Then
classeur.SaveAs Filename:=foules _
& Range("G10").Value & ".xlsx", FileFormat _
:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False 'change le fichier de sauvegarde, CTRL+F pour changer.
classeur.Close
End If
Next classeur
Application.DisplayAlerts = True
With Application
.ScreenUpdating = True
.StatusBar = False
End With
End sub |
Partager