+ Reply to Thread
Results 1 to 18 of 18

Move/Copy macro doesn't work as aspected

  1. #1
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Move/Copy macro doesn't work as aspected

    Hi.

    Got a code that will save all selected files in a directory chosen by the user.
    Often it works great but sometimes it doesn't copy/move all the selected files, just a few (about 5-6) and sometimes the new files are just 1kb and doesn't work like the program only copied the icon.

    Anyone knows a diffrent way of writing this code ? A code that doesn't bugg ?


    My Code:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by Pero; 09-25-2009 at 02:49 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Hi pero
    which line fails?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Move/Copy macro doesn't work as aspected

    sorry for slow reply !

    No line failes in the code when I run it.
    Sometimes it works and sometime it doesn't. And when you copy alot of files some of them is only 1Kb in the target folder.

    Weird..

    Just asking if its a way to write a more "Safe" code like this one.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    The only thing I can see if the sfile name or sdir string are wrong in the range
    do you have a small sample workbook?

  5. #5
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Move/Copy macro doesn't work as aspected

    Sure!

    here is a dummybook.
    Attached Files Attached Files

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    I use this code to copy file(s)
    Please Login or Register  to view this content.
    or you may need to check if
    Please Login or Register  to view this content.
    I check your code out when I get a chance
    See ya

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    ooOps

    Wrong post
    Last edited by pike; 09-17-2009 at 05:23 PM. Reason: Wrong post

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Hi Pero,
    try this..half finnished code ....
    Please Login or Register  to view this content.
    will have to add these checks
    Please Login or Register  to view this content.
    Last edited by pike; 09-18-2009 at 07:19 AM. Reason: code added line

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    this should have it
    cant find if the file exist with out the extension
    Please Login or Register  to view this content.

  10. #10
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Pero how did the code go???

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Bump Bump Bump

  12. #12
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Move/Copy macro doesn't work as aspected

    Hey!

    Have been away for a while. Will test the code now and come back with the results.
    Thaks for your time!!

    EDIT:
    WHen I run the macros I get an error. Error nr 9, "The index is out of the interval"

    I got the errormessage in swedish and thne tried to translate it. Its not a quote.

    The line markedin VBA is:
    Please Login or Register  to view this content.
    How do I fix this ?

    Again Thank you !

    //

    Per
    Last edited by Pero; 09-24-2009 at 01:03 PM.

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Pero did you select/highlight the files/folders to move or copy?

  14. #14
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Pero use..
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Move/Copy macro doesn't work as aspected

    Thank you again =)

    I'm very greatful for all of your help.
    The code is working now as it should.

    Just a few modifications need to be done.

    Everyting is explained in my DummyBok.



    //

    Per
    Attached Files Attached Files

  16. #16
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    Pero try..
    Please Login or Register  to view this content.


    Comment ; This code will differ from the email as I have to change the if to elseif
    Last edited by pike; 09-25-2009 at 04:24 AM. Reason: Comment

  17. #17
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Move/Copy macro doesn't work as aspected

    Everything is working great =)


    Thank you !!!

  18. #18
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Move/Copy macro doesn't work as aspected

    no thank you for marking the post solved

+ 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