Hallo zusammen .
Ich habe ein Tool geschrieben und zwar konvertig von csv in xlsx Dateiformat.Es ist funktioniert einwandfrei.
Trotzt brauche ich euere Unterstütztung: Fragen :
Wie kann ich, statt direkten Pfad : z.b. csvPath = "\\afspv1hom001.eu1.1corp.org\g126725$\Documents\Tool abc\"
xlsPath = "\\afspv1hom001.eu1.1corp.org\g126725$\Documents\Tool abc\"
Eine do while schliefe oder for schleife. Das die alle dateien, in dem diesem tool ist, bearbeiten werden, ohne hard codierten Pfad, sondern so z.b. :
Dim strPath As String
Dim strFile As String
Dim Pfad As String
Dim DateiName As String
strPath = ThisWorkbook.Path & "\"
strFile = Dir(ThisWorkbook.Path & "\" & "*.csv")
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Pfad = ThisWorkbook.Path & "\"
' DateiName = Dir(ThisWorkbook.Path & "\" & "*.csv")
'parF1 = Dir(Pfad & "*.csv")
'''''''''''''''''''''''''''''''''''''''''''''''''''
Do While strFile <> ""
Debug.Print strPath & strFile
___________________________
Volles programm. Eure meinungen, bitte schön :D
Danke im Voraus .
Public Sub csvToxlsx()
Dim FSO As Object
Dim folder As Object
Dim wb As Object
csvPath = "\\afspv1hom001.eu1.1corp.org\g126725$\Documents\Tool abc\"
xlsPath = "\\afspv1hom001.eu1.1corp.org\g126725$\Documents\Tool abc\"
'csvPath = "O:\Transform_Tool\"
'xlsPath = " O:\Transform_Tool\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set CSVfolder = FSO.GetFolder(csvPath)
If FSO.FolderExists(xlsPath) = False Then
FSO.createFolder (xlsPath)
End If
Set XlsFolder = FSO.GetFolder(xlsPath)
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
For Each wb In CSVfolder.Files
If LCase(Right(wb.Name, 3)) = "csv" Then
Set activeWB = Workbooks.Open(wb)
activeWB.SaveAs FileName:=xlsPath & "\" & Left(activeWB.Name, Len(activeWB.Name) - 3) & "xlsx", FileFormat:=xlOpenXMLWorkbook, Local:=True
activeWB.Close True
End If
Next
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
|