+ Reply to Thread
Results 1 to 17 of 17

renaming files not working a strange one?

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    renaming files not working a strange one?

    This is a strange one as it does appear that excel is doing exactly as it is asked however the result is incorrect.
    Basically I have two picture files whose filenames I want to swap. I am using the code
    Please Login or Register  to view this content.
    What happens is that the first two changes work correctly and I have files named temp1 & temp2 then when line three is actioned temp1 gets changed to firstname as it should BUT the picture that the filename represents changes to its original as does temp 2 when the final change is actioned. the end result being that I end up with the same files as I started with.
    I added the application.wait just to ensure the program had sufficient time to make the change though that made no difference.

    I hope I have explained this well enough, it is really strange

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    Works fine for me:
    Please Login or Register  to view this content.
    ...or
    Please Login or Register  to view this content.
    Last edited by shg; 01-31-2009 at 04:58 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Shg your code works perfectly for me as well that is if I use your picture names to test. However try naming your pictures as per the code below and then you'll see it doesn't work
    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    Still works fine:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Umm doesnt work for me, have you tried looking at thumbnail views and stepping through. what happens for me is that line 1 changes the first file OKline two chenges the second file as well BUT at the same time the actual image of the second file changes to the same as the fist so at this piont I have two images the same. Then line three changes the filename as it should but the image reverses also. the end result being the same images have the original filenames
    Does that make any sense?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    I was looking at thumbnail views, and watching them toggle.
    the end result being the same images have the original filenames
    Does that make any sense?
    Not to me, no.

    For an absolute shot in the dark, do you have windows configured to suppress file extensions for known file types?

  7. #7
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    sorry it's difficult to explain clearly so I'll try again:

    I have two images lets say fileone is a picture of a blank red card and filetwo is a picture of a blank blue card

    step 1) Image one changes filename to xxxxx (as it should)(and the thumbnail picture stays the same ie a red card)

    step 2) Image two changes filename as it should to fileone but as it does this the actual image also changes to the same as image one so now I have two images of a red card

    step 3) The xxxxx filename changes to filetwo and as it does this the thumbnail image also changes from red card to blue card.

    end result being I have fileone red card and filetwo blue card -- exactly what I started with

    Confused? I know I am

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    I understood what you meant the first time -- I just have no explanation.

    What about my question?

  9. #9
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Quote Originally Posted by shg View Post
    For an absolute shot in the dark, do you have windows configured to suppress file extensions for known file types?
    I have been looking around in the control panel/folder options for something like this but can't find it anywhere? how can I check for this?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    Open a file browser window, Tools > Folder Options, View tab, untick Hide extensions for know file types

  11. #11
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    checked that, it is already un ticked.

    Its really strange, I have even tried changing the filenames to temp1 & temp2, then changing those to second 1 and second2 then reverting back to the ones I want. I thought adding an extra step might possibly eliminate any chance of something being stored in memory anywhere but the result is still the same.

    I think I will sleep on tis and try again tomorrow.

    Thank you for your time so far, even though we haven't resolved it I appreciate your time

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    Maybe reboot your computer as well.

  13. #13
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Well I have tried everything I can think of on this one -- Looks like I'm not going to get to the bottom of of it, unless anyone else has any idea's ?

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    Good luck, tryer, wish I had another suggestion.

  15. #15
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Thanks shg, I don't think it as a problem with excel, rather something to do with the way windows stores things in memory. I have experimented with various combinations of renaming, saving the sheet, opening and closing folders etc. and I have found the results vary but not constant, sometimes it will work, other times not

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: renaming files not working a strange one?

    I agree it's a Windows thing.

    To solve the immediate problem, you could use the MoveFile method of the FileSystemObject and see if that works.

  17. #17
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: renaming files not working a strange one?

    Quote Originally Posted by shg View Post

    To solve the immediate problem, you could use the MoveFile method of the FileSystemObject and see if that works.

    Shg, I have looked up the movefile method in VBA help and can't quite understand it as it says : "If destination does not exist, the file gets moved. This is the usual case."
    Could you please explain it of offer an example,

    Thanks

+ 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