+ Reply to Thread
Results 1 to 4 of 4

Create Folders and Move Files Using VBA/MACRO

  1. #1
    Registered User
    Join Date
    07-06-2007
    Posts
    70

    Question Create Folders and Move Files Using VBA/MACRO

    Hi all,

    I'm not sure if this is even possible but here goes.

    I have a folder FULL of files.

    On each filename, the first 6 digits contains a reference number

    e.g.
    123456_456_BE.jpg
    123456_457_BE.jpg
    123456_458_BE.jpg

    For each file in the folder i want to create a folder with the name being the first 6 digits of the file (the reference).

    so for the above i would end up with one folder named 123456 and that would have three files inside -
    123456_456_BE.jpg
    123456_457_BE.jpg
    123456_458_BE.jpg

    thanks in advance

    Cj

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Create Folders and Move Files Using VBA/MACRO

    Here is one way.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-17-2010
    Location
    TN
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Create Folders and Move Files Using VBA/MACRO

    I tried the sample macro above and it worked great until I attempted to move a file to a network folder on a sharepoint site. I've been able to save excel files to these folders using VBA and would love to be able to move other files into them as well. Does anyone have any suggestions or can I just not save files to a sharepoint site this way?

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Create Folders and Move Files Using VBA/MACRO

    Not sure about sharepoint but you could try changing the .movefile to .copyfile and see if this works. If it does you can then just delete the original file as the following line in the code.

    What error does it come up with?


    click on the * Add Reputation if this was useful or entertaining.

+ 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