Solved

MS Access VBA progamatially "Write these files to CD"

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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
Battlestar Galactica ?

mx
0
 

Author Comment

by:StarbuckLives
Comment Utility
Best Drama on TV!
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 34

Expert Comment

by:jefftwilley
Comment Utility
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
Comment Utility
That's a good article Rocki...<<<Adds to Favorites>>>
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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
Comment Utility
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
Comment Utility
that link I provided had sample code, did u see it?
0
 

Author Comment

by:StarbuckLives
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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.

772 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

12 Experts available now in Live!

Get 1:1 Help Now