none
Problem to copy file RRS feed

  • Question

  • Hi,
    I am able to run 
    copy "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\.\Feb0.xlsm" "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\..\China\AsiaPacific_Budget_HO China_2016-Feb.xlsm"/y
    


    on Windows prompt, but I have got "File not found" problem like


    if I issue the same, within VBA codes, using "Shell" to run the command. Why?

    Many Thanks & Best Regards, Hua Min

    Thursday, March 31, 2016 8:48 AM

Answers

  • Hi,

    The "File not found" error is relative to the file was not found for the given path. Please check whether the path for the file is correct. We can copy it to the File Explorer to validate the file path.

    And to use Scripting.FileSystemObject in early binding, we need to set the reference via Tools->References like below:

    In addition, this forum is for developers discussing Excel developing issues like Excel automation, customization and etc. If you still have problem with VBA developing, I suggest that you reopen a new thread in Visual Basic for Applications (VBA) forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. 

    Thanks for your understanding.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 1, 2016 2:52 AM
    Moderator
  • Try using the FileSystemObject - set a reference to MS Scripting Runtime, and use code like

    Sub FSOTest()
        Dim FSO As Scripting.FileSystemObject
        FSO.CopyFile _
        "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\.\Feb0.xlsm", _
        "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\..\China\AsiaPacific_Budget_HO China_2016-Feb.xlsm"
    End Sub

    • Marked as answer by Jackson_1990 Saturday, April 2, 2016 3:08 AM
    Thursday, March 31, 2016 4:16 PM

All replies

  • Try using the FileSystemObject - set a reference to MS Scripting Runtime, and use code like

    Sub FSOTest()
        Dim FSO As Scripting.FileSystemObject
        FSO.CopyFile _
        "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\.\Feb0.xlsm", _
        "\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\China-Cnsnh\..\China\AsiaPacific_Budget_HO China_2016-Feb.xlsm"
    End Sub

    • Marked as answer by Jackson_1990 Saturday, April 2, 2016 3:08 AM
    Thursday, March 31, 2016 4:16 PM
  • Thanks. I now get this problem

    Many Thanks & Best Regards, Hua Min

    Friday, April 1, 2016 1:58 AM
  • Hi,

    The "File not found" error is relative to the file was not found for the given path. Please check whether the path for the file is correct. We can copy it to the File Explorer to validate the file path.

    And to use Scripting.FileSystemObject in early binding, we need to set the reference via Tools->References like below:

    In addition, this forum is for developers discussing Excel developing issues like Excel automation, customization and etc. If you still have problem with VBA developing, I suggest that you reopen a new thread in Visual Basic for Applications (VBA) forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. 

    Thanks for your understanding.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 1, 2016 2:52 AM
    Moderator
  • Thanks.

    Where to get into the above option, within Outlook 2010?


    Many Thanks & Best Regards, Hua Min

    Friday, April 1, 2016 3:29 AM
  • Open the VBE editor by pressing Alt & F11 and click the "Tools" on the menu bar like figurine below:

    Then check the "Microsoft Script Runtime" like the preview post.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 1, 2016 9:10 AM
    Moderator