Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts

    copy a file via VB (Access 2003)

    Want to copy Excel file from network drive to local drive. Using copyfile command below but returns Run-time error 424 "Object Required"
    Probably missing supporting code. Code assigned to a form button

    FileSystemObject.CopyFile "Cacx0140 Reportsopen sales orders.xls", "c:"

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: copy a file via VB (Access 2003)

    You can use FileSystemObject like this:
    <code>
    CreateObject("Scripting.FileSystemObject").CopyFil e "Cacx0140 Reportsopen sales orders.xls", "c:"
    </code>
    Or you can use the old Basic instruction FileCopy:
    <code>
    FileCopy "Cacx0140 Reportsopen sales orders.xls", "c:"</code>

  3. #3
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: copy a file via VB (Access 2003)

    Using CreateObject produces "Path not Found" error. The path is good because my other code is able to find it. The other code opens the excel at that path and then does "save as" to C: I'm wanting to copy the file to C: without opening. Other code is below

    Dim xlApp As Object
    Dim xlwbk As Object
    Dim strOriginalPath As String
    Dim strDesktop As String
    Dim strFile As String
    Dim strTargetPath
    strOriginalPath = "Cacx01oracle_forms40 Reportsopen sales orders"
    strFile = "Open Sales Orders.xls"
    strTargetPath = "c:"
    'open excel
    Set xlApp = CreateObject("Excel.Application")
    'Open spreadsheet
    Set xlwbk = xlApp.Workbooks.Open(strOriginalPath & strFile)
    'Save as and close it
    xlwbk.SaveAs strTargetPath & strFile
    xlwbk.Close SaveChanges:=True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •