Solved

MS Access VBA progamatially "Write these files to CD"

Posted on 2007-04-11
12
678 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
  • 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
 

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 500 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DSum for Access 6 43
Sum Multiple Columns in Access Query 5 48
running an update statement after a msgbox (MS Access) 3 28
DBF to ... Converter 5 29
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

929 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

15 Experts available now in Live!

Get 1:1 Help Now