+ Reply to Thread
Results 1 to 6 of 6

copy file from path to path

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    michigan, usa
    MS-Off Ver
    2016
    Posts
    3

    copy file from path to path

    so i have this program it does copy a file from path to path but when the does already exist it overwrite the original one, what im trying to do it when it already exist just copy the necssary lines that changed in the excel file.

    thank you in advance

    this is my program

    Sub Copy_Certain_Files_In_Folder()

    Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String
    Dim FileExt As String

    FromPath = "N:\1300\1310\BOM"
    ToPath = "S:\Bills of Materials - Shipping & Receiving\1400s"

    FileExt = "*.xlsx*"

    If Right(FromPath, 1) <> "\" Then
    FromPath = FromPath & "\"
    End If

    Set FSO = CreateObject("scripting.filesystemobject")

    If FSO.FolderExists(FromPath) = False Then
    MsgBox FromPath & " doesn't exist"
    Exit Sub
    End If

    If FSO.FolderExists(ToPath) = False Then
    MsgBox ToPath & " doesn't exist"
    Exit Sub
    End If

    FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
    MsgBox "You can find the files from " & FromPath & " in " & ToPath

    End Sub
    Last edited by rudyHanna; 07-25-2017 at 02:08 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,289

    Re: copy file from path to path

    Changing the original file to include the changes of the second is the same as overwriting the original file, just harder to implement.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-25-2017
    Location
    michigan, usa
    MS-Off Ver
    2016
    Posts
    3
    Quote Originally Posted by Bernie Deitrick View Post
    Changing the original file to include the changes of the second is the same as overwriting the original file, just harder to implement.
    How would implement it in the program?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,289

    Re: copy file from path to path

    Implement overwriting the original file? Easy.

    If you want to implement making the same changes to the original, then you would need to do a sheet by sheet, cell by cell comparison, for values, formulas, formatting, column width - all sorts of changes that would be included in overwriting the original file.

  5. #5
    Registered User
    Join Date
    07-25-2017
    Location
    michigan, usa
    MS-Off Ver
    2016
    Posts
    3
    Quote Originally Posted by Bernie Deitrick View Post
    Implement overwriting the original file? Easy.

    If you want to implement making the same changes to the original, then you would need to do a sheet by sheet, cell by cell comparison, for values, formulas, formatting, column width - all sorts of changes that would be included in overwriting the original file.
    Is there anyway you could give me an example how would you do?

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,289

    Re: copy file from path to path

    Code with logic like this - untested...

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Separate complete path to file and directory path
    By drgkt in forum Excel General
    Replies: 19
    Last Post: 10-28-2016, 04:17 PM
  2. Choosing folder path (instead of file path) in VBA
    By sminter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 08:50 PM
  3. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  4. [SOLVED] Save As Dialog Box - Default Path and File Name, User Selects Sub Folder from Default Path
    By christenprochaska in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 05:17 PM
  5. Specified folder path to select file path
    By JayEmTee91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 10:38 AM
  6. Replies: 7
    Last Post: 10-09-2009, 10:10 AM
  7. Use String Variables in File Path and create path if not existing
    By JanBang in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-26-2007, 09:04 AM

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