+ Reply to Thread
Results 1 to 4 of 4

Trouble creating a new folder on my desktop

  1. #1
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Trouble creating a new folder on my desktop

    Hi -

    Trying to check if a folder already exists in a desktop folder called 'Parent Folder'. The path is ..."C:\Users\Tom\Desktop\Parent Folder\plus the variable nFolderName. If this folder exists, I want to return a message telling the user it already exists. If the folder does NOT exist, I want to create it using the variable... nFolderName.

    What's happening when I run this code is I get a new folder named nFolderName in the folder named Parent Folder. However, when I hover over my variable in the code, I see the variable name assigned from the input box. I'm stumped!

    As a student of VBA, I really want to understand why my code is not behaving as intended. My sample workbook is attached.

    Thanks for any help.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Trouble creating a new folder on my desktop

    The path name you are using is fully within quotes. Even though it includes nFolderName, it takes "nFolderName" as the actual folder name, rather than the value of the variable. You need to separate the variable from the string:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Trouble creating a new folder on my desktop

    Try this one
    Please Login or Register  to view this content.
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  4. #4
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Re: Trouble creating a new folder on my desktop

    Thanks sixstringjazzer! That worked. And thanks for the explanation too. Very helpful learning.

    Grilleman

+ 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. [SOLVED] Trouble Updating a list of Files if a file no longer exists in the Folder/Sub Folder Dir.
    By jrtraylor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-26-2019, 02:03 AM
  2. [SOLVED] Create Folder and sub folder at desktop
    By gondal in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-13-2016, 09:31 AM
  3. Pull tab from desktop folder
    By excelnoob927 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2014, 12:37 PM
  4. Creating a folder in desktop and inside it, save new workbooks...
    By jcmc2112 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2014, 02:04 PM
  5. Make Folder on Desktop
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2009, 08:07 AM
  6. Trouble opening file from desktop...Help
    By Hootywho in forum Excel General
    Replies: 2
    Last Post: 08-03-2006, 09:15 PM
  7. Values to a folder name on desktop
    By Matt in forum Excel General
    Replies: 7
    Last Post: 05-15-2006, 01:00 PM

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