Results 1 to 3 of 3

How to copy a file from one folder to another in vba

  1. #1
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    655

    How to copy a file from one folder to another in vba

    Make sure you have no spaces in the folder/filename.


    OldName = "C:\OldFolder\SomeExample.xls"
    NewName = "C:\NewFolder\SomeExample.xls"
    retval = 0
    Dim objFSO As Object


    Set objFSO = CreateObject("Scripting.FileSystemObject")
    retval = objFSO.CopyFile(OldName, NewName, True)
    Set objFSO = Nothing
    msgbox "Copy/paste complete"

  2. #2
    tormodnt is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2009
    Posts
    1
    Could you help me with how I can get a pop up box to chose new file location instead of using a pre typed one?
    I could use this to make a backuptool of my back end db, and place it on a external drive and so on.

    If there is already a solution for something like this, you could point me in the right direction since I can't seem to find any.

    Best regards
    Tormod
    Norway

  3. #3
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    655
    There are a couple examples of this somewhere in the code repository. I can't recall what they are named though but I think you want to look for the ones which have 'browse' for files somewhere in the heading.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copy file to folder
    By tpcervelo in forum Programming
    Replies: 11
    Last Post: 08-31-2010, 10:01 AM
  2. Replies: 1
    Last Post: 05-02-2010, 05:09 PM
  3. Create Hash - Copy File to string
    By andrew_ww in forum Programming
    Replies: 0
    Last Post: 03-20-2010, 02:14 AM
  4. copy data from text file into table in access
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-12-2009, 03:02 PM
  5. Replies: 0
    Last Post: 09-18-2006, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums