AW: VBA Excel Code zum Brennen eines Ordners
02.09.2014 12:31:43
Thorsten
Folgender Code ist dort zu finden:
' This script adds data files from a single directory tree to a
' disc (a new session is added, if the disc already contains data)
' Copyright (C) Microsoft. All rights reserved.
Option Explicit
' *** CD/DVD disc file system types
Const FsiFileSystemISO9660 = 1
Const FsiFileSystemJoliet = 2
Const FsiFileSystemUDF102 = 4
WScript.Quit(Main)
Function Main
Dim Index ' Index to recording drive.
Dim Recorder ' Recorder object
Dim Path ' Directory of files to add
Dim Stream ' Data stream for burning device
Index = 0 ' First drive on the system
Path = "G:\BurnDir" ' Files to add to the disc
' Create a DiscMaster2 object to connect to optical drives.
Dim DiscMaster
Set DiscMaster = WScript.CreateObject("IMAPI2.MsftDiscMaster2")
' Create a DiscRecorder2 object for the specified burning device.
Dim UniqueId
set Recorder = WScript.CreateObject("IMAPI2.MsftDiscRecorder2")
UniqueId = DiscMaster.Item(Index)
Recorder.InitializeDiscRecorder(UniqueId)
' Create a DiscFormat2Data object and set the recorder
Dim DataWriter
Set DataWriter = CreateObject ("IMAPI2.MsftDiscFormat2Data")
DataWriter.Recorder = Recorder
DataWriter.ClientName = "IMAPIv2 TEST"
' Create a new file system image object
Dim FSI
Set FSI = CreateObject("IMAPI2FS.MsftFileSystemImage")
' Import the last session, if the disc is not empty, or initialize
' the file system, if the disc is empty
If Not DataWriter.MediaHeuristicallyBlank _
Then
On Error Resume Next
FSI.MultisessionInterfaces = DataWriter.MultisessionInterfaces
If Err.Number 0 _
Then
WScript.Echo "Multisession is not supported for this disc"
Main = 1
Exit Function
End If
On Error Goto 0
WScript.Echo "Importing data from the previous session..."
FSI.ImportFileSystem()
Else
FSI.ChooseImageDefaults(Recorder)
End If
' Add the directory and its contents to the file system
WScript.Echo "Adding " & Path & " directory to the disc..."
FSI.Root.AddTree Path, false
' Create an image from the file system image object
Dim Result
Set Result = FSI.CreateResultImage()
Stream = Result.ImageStream
' Write stream to disc using the specified recorder
WScript.Echo "Writing content to the disc..."
DataWriter.Write(Stream)
WScript.Echo "Finished writing content."
Main = 0
End Function
Mir fehlt dabei das Verständis. Es zeigt mir Fehlermeldungen an und lässt sich nicht ausführen. Kann mir dabei jemand helfen?
VG Thorsten