+ Reply to Thread
Results 1 to 16 of 16

Copying and moving files - or just renaming?

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Copying and moving files - or just renaming?

    Hellow everyone. i have several files:

    CDS
    Formulas
    Illiquid
    Q
    Rules
    Special_Trades,

    and they are found here: "L:\12_31_2009_105_Support_Summaries\".

    I would like to copy those files and place them into the folder "MM_DD_YYYY_157_Support_Summaries" which is created in the following code below, via a userform.

    Please Login or Register  to view this content.
    Thanks for any help.
    Last edited by AnthonyWB; 04-09-2010 at 10:50 AM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    I beleive this would do it, though I've not personally ever used this command. Assuming these are excel files, you may have to add the extension to the end.

    Please Login or Register  to view this content.


    Please let me know if that does not work.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    "Public Sub AnthonyWB()"

    Variable not defined?

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    Hmm, Does excel 07 have FileCopy? Go to it in the code and press F1.
    There are no variables in the code, so I'm not sure why the error message would display.

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    Yep, it has it. I wonder why it does not work?

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    I don't know, I started stepping through it on my machine and it worked fine. Are you sure you copied it right - didn't leave out any " or &.

    You did just add it into your previous procedure, right? You can see I used your variables, so it would all have to be one macro.

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    I modified the code with the appropriate extension it still does not work:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    Here is what I am doing now, and I get an error "ambiguous name detected":

    Please Login or Register  to view this content.

  9. #9
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    Like this, all in one Sub:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    Nope, nothing is copied. Interesting?

  11. #11
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    add the .xlsm extensions to the last one I posted.

  12. #12
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    I did, please see below:

    Please Login or Register  to view this content.

  13. #13
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copying and moving files - or just renaming?

    Sorry AnthonyWB, I've been trying to do three things at once and none of them worked out well. It turns out you need to include the filename where you want it copied:

    Please Login or Register  to view this content.

    The help in VBA for this is almost useless, the example has no file extension and no path. They seem to use variables without defining them...

  14. #14
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    I have to do this, someone should be able to help?

  15. #15
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    Dave, I tried the code below per your suggestion, still no go. Perhaps I am missing something - such as the files may be read only or something?

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Copying and moving files - or just renaming?

    I got it, I simply created a sub module and ran the code. Thank you very much.

+ 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