Link to home
Start Free TrialLog in
Avatar of anthonytr
anthonytrFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Burn CD from MS Access

Hi,

I'm looking at adding a burn files to CD option in my MS Access database.  My database includes the path to the folder with the files which need to be burned to the CD.

The code I have found is below, however, it doesnt seem to work.  It errors out at :

strDriveLetter = Application.InputBox("Driveletter : ", "Driveletter", "D", Type:=2) & ":\"  

Can anyone help?

Sub burn_a_cd() 
     'Provide the drive letter of your CD burner
    strDriveLetter = Application.InputBox("Driveletter : ", "Driveletter", "D", Type:=2) & ":\" 
     'Provide the source directory. We made one on the c drive
     'and everything we put in this directory will be put on a cd
    strSourceDirectory = "C:\TOBURN" 
     'Provide a volume name for your CD (16 characters max)
    strCDName = Date 
    Const MY_COMPUTER = &H11 
    Set WShshell = CreateObject("WScript.Shell") 
    Set objShell = CreateObject("Shell.Application") 
    strBurnDirectory = WShshell.RegRead( _ 
    "HKCU\Software\Microsoft\Windows\CurrentVersion\" _ 
    & "Explorer\Shell Folders\CD Burning") 
    Set objFolder = objShell.Namespace(strSourceDirectory) 
    objShell.Namespace(strBurnDirectory).CopyHere objFolder.Items 
    objShell.Namespace(&H11&).ParseName(strDriveLetter).InvokeVerbEx ( _ 
    "Write &these files to CD") 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anthonytr

ASKER

That's great - thank you
You are welcome!

/gustav