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
| strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\log\log1.txt")
objExcel.Visible = True
i = 1
Do Until objExcel.Cells(i, 1).Value = ""
strOldFolderName = objExcel.Cells(i, 1).Value
strNewFolderName = objExcel.Cells(i, 2).Value
strOldFolderName = Replace(strOldFolderName, "\", "\\")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = '" & strOldFolderName & "'")
For Each objFolder in colFolders
errResults = objFolder.Rename(strNewFolderName)
Next
i = i + 1
Loop
aussi avce ceci et ca marche pa ilya des erreurs
Sub importExcelCrochet()
Range("A3").Select
Workbooks.Add
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\log\log1.txt", _
Destination:=Range("A1"))
.Name = "ImpExcel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "]"
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Application.CommandBars("External Data").Visible = False
End Sub |
Partager