After a lot of net searching I finally found some code which looks promising and to my eyes looks as though it could be just what I have been looking for for my project.
I have been trying to automate the CD Burning process from within my MS Access database and have been playing around with a number of options, but nothing has quite worked yet.
In my database, every Batch_Reference also has a link to a Dir which contains a number of scanned .tiff files. Once the batch has been completed the user clicks to burn batch to CD, inserts and CD and the Dir is burned straight onto the CD-R or DVD-R. The CD is also given the name of the Batch_Reference.
The Following code I found, successfully burns the CD, however, it burns a multi-sessions CD and does not Finalize the CD. Also, I can't seem to find how to manage the naming of the CD from within the code.
It seems that this example is oh so close to what I have been searching for and yet so far. I really do someone can help me out with this project.
Option Compare Database
Dim objDiscMaster As IMAPI2.MsftDiscMaster2
Dim objRecorder As IMAPI2.MsftDiscRecorder2
Dim DataWriter As IMAPI2.MsftDiscFormat2Data
Dim intDrvIndex As Integer
'The Object browser, but not intellisense, presents types for these, but they cannot be used in VBA
Dim stream As Variant
Dim FS As Variant
Dim Result As Variant
Dim FSI As Object
Dim strBurnPath As String
Dim strUniqueID As String
' *** CD/DVD disc file system types
Const FsiFileSystemISO9660 = 1
Const FsiFileSystemJoliet = 2
Const FsiFileSystemUDF102 = 4
'On Error GoTo TestCDWrite_Error
intDrvIndex = 0
strBurnPath = "C:\TempPDF" 'I will eventually set this via a variable
' Create a DiscMaster2 object to connect to optical drives.
Set objDiscMaster = New IMAPI2.MsftDiscMaster2
' Create a DiscRecorder2 object for the specified burning device.
Set objRecorder = New IMAPI2.MsftDiscRecorder2
strUniqueID = objDiscMaster.Item(intDrvIndex)
' Create a DiscFormat2Data object and set the recorder
Set DataWriter = New IMAPI2.MsftDiscFormat2Data
DataWriter.recorder = objRecorder
DataWriter.ClientName = "IMAPIv2 TEST"
' Create a new file system image object
Set FSI = New 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
Call MsgBox("Multisession is not supported on this disc", vbExclamation, "Data Archiving")
On Error GoTo 0
Call MsgBox("Importing data from previous session ...", vbInformation, "Data Archiving")
FS = FSI.ImportFileSystem()
FS = FSI.ChooseImageDefaults(objRecorder)
' Add the directory and its contents to the file system
Call MsgBox("Adding " & strBurnPath & " folder to the disc...", vbInformation, "Data Archiving")
FSI.Root.AddTree strBurnPath, False
' Create an image from the file system image object
Set Result = FSI.CreateResultImage()
Set stream = Result.ImageStream
' Write stream to disc using the specified recorder
Call MsgBox("Writing content to the disc...", vbInformation, "Data Archiving")
Call MsgBox("Completed writing Archive data to disk ", vbInformation, "Data Archiving")
'Error handling block
Select Case Err.Number
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "TestCode.TestCDWrite"
'End Error handling block