+ Reply to Thread
Results 1 to 4 of 4

Excel VBA get name of highlighted folder - edit name

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    SW US
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    Excel VBA get name of highlighted folder - edit name

    I would like to run this in Excel 2007 --

    I have a recurring problem where co-workers have named folders under R:/All Companies/ABC Company (examples) -- and then subfolders: ABC Company 1Q2009, ABC Company 2Q2009, ABC 3Q2012.
    Am using Windows XP (company edict). Naturally, these folders sort by the Quarter, then by the year. They should sort by the year, then by the quarter so I want to:

    Loop through the highlighted subfolder ABC Company, put each sub-subfolder name into a variable in VBA code and then have a User Input box popup that says "The current sub-subfolder is [variable ex: ABC Company 2Q2009]. Please key in the full NEW name of the folder." The user then keys in "ABC Company 2009Q1". Hits OK and the VBA loops to the next sub-sub folder, etc.

    Since the folder names are not consistent -- for example...everyone using the above (incorrect) file naming structure, someone else might use "XYZ Co - 3Q01", it is not possible to edit or change the current folder name....the user (me) needs to be able to key in an entirely new, correct name.

    I want to start on the sub-sub folder..... in other words, highlight R:/All Companies/<the name of the Company>.

    I am fairly decent at Access VBA but I just haven't used Outlook VBA enough to know my way around.

    Thanks for your help.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA get name of highlighted folder - edit name

    Where would the folders be 'highlighted?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-24-2012
    Location
    SW US
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    Re: Excel VBA get name of highlighted folder - edit name

    Good question. I use 2 monitors. So, I would have Explorer open on the left and highlight the folders there and run the Excel VBA on the right. If I can do it that way.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA get name of highlighted folder - edit name

    I think you would need Windows API if you are going to work from the folder selected in Windows Explorer.

    In VBA, without reference to Explorer, if you had 'root' folder then you could write code to list all the subfolders under it.

    That list could be put on a worksheet, then you could go through it and where needed put the new name for each folder in the next column.

    Then you could have code that goes through the list and renames the folders.

+ 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. edit macro to make it run on all files in a folder
    By rohit43 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-09-2013, 05:46 PM
  2. [SOLVED] VB Macro To Take Highlighted Cells & Create Folder name from it.
    By aelingil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2013, 01:24 PM
  3. [SOLVED] Loop Through all files in a folder and use the same macro to edit each one.
    By dj59 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2012, 06:56 PM
  4. Replies: 2
    Last Post: 07-09-2009, 11:36 PM
  5. ref edit for folder directory on cpu
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2007, 12:04 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