Code Snippet "VBA Excel"
Für alle Dateien in einem Verzeichnis INSERT-Statements generieren
Sub fileloop()
Const STR_FOLDER As String = "\\Dyna2003-05\zu_archivieren\"
Dim objfile
Dim objfolder
Dim objfs
Set objfs = CreateObject("Scripting.FileSystemObject")
Range("A1").Select
If objfs.FolderExists(STR_FOLDER) Then
Set objfolder = objfs.GetFolder(STR_FOLDER)
For Each objfile In objfolder.Files
'In Kombinationsfeld
ActiveCell.Value = "INSERT INTO tmpdokname (dokname) VALUES('" _
& objfile.Name & "');"
Selection.Offset(1, 0).Select
Next
End If
End Sub