?
Solved

MS Access VBA progamatially "Write these files to CD"

Posted on 2007-04-11
12
Medium Priority
?
684 Views
Last Modified: 2012-05-05
I'm using access to copy a file from my pc to a CD-R. I can copy the file to ""\Local Settings\Application Data\Microsoft\Cd Burning" using FileCopy, since, for some reason I can't burn it directly to the cd drive (D:\). That works like a charm.

But then it just says that I have files waiting to be burned to the CD. How do I programatically get to the next step; the equivalent to clicking on "File:Write these files to CD"?

I'm assuming it's a SHELL command? Maybe? Anyone?
0
Comment
Question by:StarbuckLives
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 75
ID: 18891942
Battlestar Galactica ?

mx
0
 

Author Comment

by:StarbuckLives
ID: 18891990
Best Drama on TV!
0
 
LVL 75
ID: 18892083
Hummmmm .... well ... '24' ... then BSG ... :-)

btw ....I know the answer off hand ... sorry ... but, ahhh ... could you hook me up with Starbuck ???

mx
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:StarbuckLives
ID: 18892135
My friend... if I had an 'in' with Starbuck, I wouldn't be here trying to figure this out!
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 1000 total points
ID: 18892287
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18892436
good post Jeff, u can find an example using ICBurn here (no points pls - Jeff posted ICBurn first!) http://www.vbaccelerator.com/home/VB/Code/Libraries/Writing_CDs/Simple_CD_Burn/article.asp (look at the bottom of the page)
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18892437
I found this one too...but I'm websensed..so I couldn't open it

Looks like exactly what You need:
http://www.freedownloadscenter.com/Best/burn-cd-vb_net.html
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18892557
That's a good article Rocki...<<<Adds to Favorites>>>
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18892581
Well I happen to stumble across that, just so happens u posted ICBurn as well. So u take the credit on this one (thats if ICBurn is used)
0
 

Author Comment

by:StarbuckLives
ID: 18898356
Okay, I'm looking at the code. But how do I apply it to VBA in Access? This is the code I have to copy the file to the "on deck" circle to be burned to CD:

Function fOSUserName() As String

Dim lngLen As Long, lngX As Long
Dim strUserName As String

    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
   
shortname = Left(strUserName, 8)

SourceFileA = "c:\MAPBACKUP\mapbu.zip"
DestinationFileB = "C:\Documents and Settings\" & shortname & "\Local Settings\Application Data\Microsoft\Cd Burning\" & Format(Date, "mmddyy") & "MBU.zip"
FileCopy SourceFileA, DestinationFileB
           
End Function

What code/part of code do I have to add to burn it to the CD?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18898623
that link I provided had sample code, did u see it?
0
 

Author Comment

by:StarbuckLives
ID: 18898998
I'm sorry, I'm not getting my head around this.  I added this code to the top:

Private Const FAIL_BIT As Long = &H80000000

Private Function FAILED(ByVal hResult As Long) As Boolean
   FAILED = ((hResult And FAIL_BIT) = FAIL_BIT)
End Function

Knowing that we can now instantiate the object:

Private m_cdBurn As ICDBurn

Public Sub Initialise(ByVal hWndOwner As Long)

   ' Set up the CLSID of the Shell Extension which
   ' contains the ICDBurn implementation:
   Dim clsidCDBurn As UUID
   With clsidCDBurn
      .Data1 = &HFBEB8A05
      .Data2 = &HBEEE
      .Data3 = &H4442
      .Data4(0) = &H80
      .Data4(1) = &H4E
      .Data4(2) = &H40
      .Data4(3) = &H9D
      .Data4(4) = &H6C
      .Data4(5) = &H45
      .Data4(6) = &H15
      .Data4(7) = &HE9
   End With

   ' Set up the IID of the ICDBurn interface which
   ' we want to obtain:
   Dim iidCDBurn As UUID
   With iidCDBurn
      .Data1 = &H3D73A659
      .Data2 = &HE5D0
      .Data3 = &H4D42
      .Data4(0) = &HAF
      .Data4(1) = &HC0
      .Data4(2) = &H51
      .Data4(3) = &H21
      .Data4(4) = &HBA
      .Data4(5) = &H42
      .Data4(6) = &H5C
      .Data4(7) = &H8D
   End With
   
   ' Create the instance of the object:
   Dim hr As Long
   hr = CoCreateInstance( _
      clsidCDBurn, Nothing, CLSCTX_INPROC_SERVER, _
      iidCDBurn, m_cdBurn)
   If (FAILED(hr)) Then
      Err.Raise ERR_BASE + 1, App.EXEName & ".cSimpleCDBurner", _
         "Failed to instantiate CDBurn implementation"
   End If
   m_hWndOwner = hWndOwner

End Sub


and I added the bottom code to my function so it looks like this now:

Function fOSUserName() As String

Dim lngLen As Long, lngX As Long
Dim strUserName As String

    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
   
shortname = Left(strUserName, 8)

SourceFileA = "c:\MAPBACKUP\mapbu.zip"
DestinationFileB = "C:\Documents and Settings\" & shortname & "\Local Settings\Application Data\Microsoft\Cd Burning\" & Format(Date, "mmddyy") & "MBU.zip"
FileCopy SourceFileA, DestinationFileB
           
Private m_cBurn As New cSimpleCDBurner


   Set m_cBurn = New cSimpleCDBurner

   ' Note that the
   m_cBurn.Initialise Me.Hwnd

   ' Get the staging area:
   Dim sStagingArea = m_cBurn.BurnStagingAreaFolder

   ' Copy files and folders to the staging area here

   ' Finally burn the CD
   m_cBurn.Burn

   
End Function

But it says 'Invalid attribute in Sub or Function' and highlights the Private in 'Private m_cBurn As New cSimpleCDBurner' and it doesn't like ' Dim sStagingArea = m_cBurn.BurnStagingAreaFolder'. Should it be:

Dim sStagingArea
sStagingArea = m_cBurn.BurnStagingAreaFolder

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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