Dafür habe ich mir folgenden Code "geklaut":
Option Explicit
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long
Sub SpeichernUnter()
Dim strFilePath As String
Dim strExt As String, lngFormat As Long
Const cstrStdPath = "Y:\Melktechnik\Kunden\"
getFileExtAndFormat ThisWorkbook, strExt, lngFormat
With ThisWorkbook
With .Worksheets("Hilfstabelle")
strFilePath = cstrStdPath & IIf(Right(cstrStdPath, 1) = "\", "", "\") & _
.Range("B2") & IIf(Right(.Range("B2"), 1) = "\", "", "\") & _
.Range("B5") & IIf(Right(.Range("B5"), 1) = "\", "", "\") & _
.Range("B6") & IIf(Right(.Range("B6"), 1) = "\", "", "\") & .Range("B1") & .Range("B2") & strExt
End With
If MakeSureDirectoryPathExists(strFilePath) 0 Then .SaveAs strFilePath, lngFormat
End With
End Sub
Private Function getFileExtAndFormat(ByRef WB As Workbook, ByRef strExt As String, ByRef _
lngFormat As Long)
With WB
If Val(Application.Version)
Es wird unter Y:\Melktechnik\Kunden\ nun noch ein Kundenordner mit Kundenname und Kundennummer (Info kommt aus Zelle B2) erstellt, darin ein Ordner Auftragsnummer (Info kommt aus Zelle B5) und darin ein Ordner "Aufträge" mit der Datei gespeichert.
Soweit alles Prima.
Nun stellt sich folgende Aufgabe:
- ich möchte im Ordner, der aus Zelle B5 erstellt wird nicht nur den Ordner Aufträge erstellen, sondern zusätzlich weitere Ordner einfügen, bspw. Bilder, Schriftverkehr, Protokolle, etc. ohne, dass darin eine Datei gespeichert wird.
Ist das Möglich?
MfG Marc