+ Reply to Thread
Results 1 to 4 of 4

Copying and and renaming files based on OldFileName As String, NewFileName

  1. #1
    Registered User
    Join Date
    05-18-2013
    Location
    holland
    MS-Off Ver
    Excel 2011
    Posts
    27

    Copying and and renaming files based on OldFileName As String, NewFileName

    Hi ty in advance for reading this i hope you guys could help me out i am alredy stuck for like 7 hours T-T

    any way this is what i would like to create

    i have a work sheet whit 2 rows A and B

    in Row A i have origenal files path here is a example

    C:\Users\valeri kovtoen\Desktop\test\oud\DIS Frozen\Frozen Winter Cushion\pillow.jpg

    in the other i have the new directory for what name it should get and ware it should go

    C:\Users\valeri kovtoen\Desktop\test\new\WF0223134001.jpg

    so basecly i need excel to look in the dir path find pillow.jpg copy it an place in a new dir whit a new name WF03324.jpg


    there are some problems the orignale files have difrent dirs here is a example


    C:\Users\valeri kovtoen\Desktop\test\oud\folder1\image1.jpg
    C:\Users\valeri kovtoen\Desktop\test\oud\folder2\image1.jpg

    also some times a image wil be used multiple times here is a examp

    C:\Users\valeri kovtoen\Desktop\test\oud\folder2\image1.jpg to 000056.jpg
    C:\Users\valeri kovtoen\Desktop\test\oud\folder2\image1.jpg to 000043.jpg
    C:\Users\valeri kovtoen\Desktop\test\oud\folder2\image1.jpg to 000045.jpg

    and the last problem is that some times the image might not exist so id that happen it should ignor it and continie

    sorry for my typo's and hope you guys could help me i tried thise code but it gives me

    run-time error 52
    Bad file name or number

    here is my curent code:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copying and and renaming files based on OldFileName As String, NewFileName

    Try this. You may have to add a test to see if the destination path exists.
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    05-18-2013
    Location
    holland
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: Copying and and renaming files based on OldFileName As String, NewFileName

    tyvm for helping me ^^ i tried your code but still the same error T-T

    if i debug it hilights this: If Not Dir(OldFileName) = "" Then

    here are the first couple cels the totaal is about 1500

    old new
    C:\Users\valeri kovtoen\Desktop\test\oud\DIS Frozen\Frozen Winter Cushion\Frozen Winter Cushion.jpg to C:\Users\valeri kovtoen\Desktop\test\new\5055285344498.jpg
    C:\Users\valeri kovtoen\Desktop\test\oud\DIS Frozen\Frozen Winter Poncho\Frozen Winter Poncho.jpg to C:\Users\valeri kovtoen\Desktop\test\new\5055285344528.jpg
    Last edited by western; 07-16-2015 at 04:42 PM. Reason: forgot some info

  4. #4
    Registered User
    Join Date
    05-18-2013
    Location
    holland
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: Copying and and renaming files based on OldFileName As String, NewFileName

    i just cheakd my files it looks like the error came from that i was missing some files i have replaced all the image files and now it gives a other error Run-time error 70 permission denied T-T

+ 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. Replies: 0
    Last Post: 10-15-2014, 04:37 AM
  2. Can anyone here tweek this macro for renaming Excel files based on a cell's contents?
    By chrisd2000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-01-2014, 02:43 PM
  3. Replies: 1
    Last Post: 01-15-2013, 03:05 AM
  4. Creating, copying and renaming new worksheet based on specific cell contents
    By johnejo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 01:16 PM
  5. Copying and renaming files based on timestamp VBA
    By jr.benk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2011, 11:26 AM
  6. Copying and moving files - or just renaming?
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-09-2010, 10:49 AM
  7. Renaming files from a number string inside the file.
    By Gordon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2006, 01:10 PM

Tags for this Thread

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