+ Reply to Thread
Results 1 to 3 of 3

Create backup copy of excel file in VB

Hybrid View

  1. #1
    Registered User
    Join Date
    10-30-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Create backup copy of excel file in VB

    Hi
    In VB macro, looking for an easy way to copy a file in one directory to another directory and overwriting the file in the destination directory. Any ideas, the web has suggested below which give me an error!

    a = "G:\Database\t.txt"
    b = "G:\Database\Archive\tcopy.txt"
    My.Computer.FileSystem.CopyFile( a , b , _
    FileIO.UIOption.OnlyErrorDialogs, _
    FileIO.UICancelOption.DoNothing)

    Thanks, copying files is much cleaner than opening the file and copying the cells!

    Greg

  2. #2
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Create backup copy of excel file in VB

    I had a similar issue and have used the following code to create a backup file. http://www.rondebruin.nl/folder.htm

    Sub Copy_One_File()
    
        FileCopy "G:\Database\t.txt", "G:\Database\Archive\tcopy.txt" 
    
    End Sub
    You may also want to check out Ron De Bruin, he has many helpful tips for many versions of Excel.

    PS - You may want to edit your post and wrap your code by highlighting it and clicking on the #, it's per the forum rules

  3. #3
    Registered User
    Join Date
    10-30-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Create backup copy of excel file in VB

    Wolfman,
    Thanks for your help, worked great. I have already been scolded by the hall monitor about wrapping my code and will do so in the future.

    Thanks all, great forum!!

    Greg

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1