Burnd CD from VBA in MS Access


I had been developing a simple database with CD burning capabilities a year ago and have returnd to the programme to continue its development and have run into an issue.  In the 'Burn CD' code I get an error "Run Time Error '5' : Invalid procedure call or argument.  It debugs at the following line:

strUniqueID = objDiscMaster.Item(intDrvIndex)

The complete line of code is:

Sub TestCDWrite()
  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:\Toburn"
  ' 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)
  objRecorder.InitializeDiscRecorder (strUniqueID)

  ' Create a DiscFormat2Data object and set the recorder
  Set DataWriter = New IMAPI2.MsftDiscFormat2Data
  DataWriter.Recorder = objRecorder
  DataWriter.ClientName = "IMAPIv2 TEST"
  DataWriter.ForceMediaToBeClosed = True
  ' Create a new file system image object
  Set FSI = New IMAPI2FS.MsftFileSystemImage
    FSI.VolumeName = "TestCDReference"
    FS = FSI.ChooseImageDefaults(objRecorder)

  ' Add the directory and its contents to the file system
  Call MsgBox("Adding " & strBurnPath & " folder to the disc.  Press OK to continue.", vbInformation, "Burn Batch to CD")
  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("Burn Batch to disc.  Press OK to continue.", vbInformation, "Burn Batch to CD")
  DataWriter.Write (stream)
  Call MsgBox("Burn process completed.", vbInformation, "Burn Batch to CD")
  Exit Sub
'Error handling block
  Select Case Err.Number
   Case Else
   MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "TestCode.TestCDWrite"
  End Select
  Resume ExitHere
'End Error handling block

End Sub

Open in new window

I am running windows 10 and Access 13.  

Any ideas what is going on?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
So are you saying that this code worked before?
What has changed since then?
anthonytrAuthor Commented:
nothing has changed in the code, except for my OS and possibly the Microsoft Access Version.
Jeffrey CoachmanMIS LiasonCommented:
Not really an answer, ..but the OS version will be the first place to start.
Remember that W10 was only just recently released, and there will be bugs to work out.

Also know that if you built this app around a 32 bit OS, and now W10 is 64 bit, ...then some code changes will be needed.

Let's see what other Experts may contribute...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anthonytrAuthor Commented:
I reverted back to Windows 7 and was able to continue with my project.  Looks like the Windows 10 upgrade wasn't the best thing to do.

Thanks Jeffrey for pointing this out (it saved a lot of poking around in my code).

Jeffrey CoachmanMIS LiasonCommented:
But if you find a solution within 21 days, post it here.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.