+ Reply to Thread
Results 1 to 6 of 6

Macro move folder and rename

  1. #1
    Registered User
    Join Date
    12-20-2006
    Posts
    34

    Macro move folder and rename

    Hi All,

    Wonder if anyone out there can help with this one.
    I've created a macro which does the following:-
    1. Creates a new folder within a folder.
    2. Creates two more subfolders within the folder above.
    3. Saves the active workbook to one of the subfolders and allows you to name it.

    All of the above works very nicely except for two problems:-

    1. When you try and run the macro again, a message appears telling you that the folder already exists.
    In order to prevent this, one has to manually delete the folder.

    2. The code that should alter the folder path does not seem to work.

    My idea (this is the question/problem)is to rename the folder and/or move it to another location.

    Any help would be much appreciated.

    The code so far is shown below.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 03-16-2007 at 06:12 PM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See if this code can help you (each section is complete; if you copy more than one section delete the first two rows (dim and set) from the sections other the first):

    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    03-13-2007
    Location
    Metro Atlanta
    Posts
    48
    Antonio,

    I tried this after placing an xls file in the last folder.
    '---> DELETE A PATH <---
    Please Login or Register  to view this content.
    I got permission denied but it deleted the file.
    Only after I exit and reopen Excel would it delete the folder.

    Do you know of a way to do it within the same Excel session?

    Thanks,
    -ern2ern
    Last edited by VBA Noob; 03-16-2007 at 06:12 PM.

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    I think the problem is you try to delete a path where you opened a file and the file lock the path.

    I think you can't delete it if there are opened files.

    Regards,
    Antonio

  5. #5
    Registered User
    Join Date
    12-20-2006
    Posts
    34
    Hi Guys,

    Thanks for your input so far. I have tried the code you suggested but it does not do what I want it to.
    Essentially, I need to move a folder containing two subfolders, including the files, from one directory to another.

    Any further suggestions.

    Bodz

  6. #6
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Did you try to use this code:

    Please Login or Register  to view this content.
    I hope you can fix your problem
    Regards,
    Antonio

+ 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