Solved

Burn CD from MS Access

Posted on 2014-04-06
3
808 Views
Last Modified: 2014-04-06
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

0
Comment
Question by:anthonytr
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
This should do:

strDriveLetter = InputBox("Driveletter: ", "Driveletter", "D") & ":\"

/gustav
0
 

Author Comment

by:anthonytr
Comment Utility
That's great - thank you
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
You are welcome!

/gustav
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now