Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Jan 2005
    Location
    Gwent, Wales
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create User Defined Folder (Excel 2002)

    Hi,

    I need some help. I'm trying to provide a way in which a user is presented with the file structure of his PC and is asked to create a new folder (something like the FileDialog function etc). When he does this I need to know the name of the new folder and its location. I will then be able to copy a defined folder structure into his new folder along with some files. I think that I can do the second part, but have no idea about the first. Can anyone help?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create User Defined Folder (Excel 2002)

    See if you can use the function in <post#=443270>post 443270</post#>. The user can select an existing folder or create a new one; the complete path of the selected/created folder is returned, including a trailing backslash.

  3. #3
    Lounger
    Join Date
    Jan 2005
    Location
    Gwent, Wales
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create User Defined Folder (Excel 2002)

    Perhaps I should have mentioned that the user gets to press a button which runs a macro etc. So in this case the user sees a buttion "Create Folder". How do I call this function, or get it to run from a macro? At the moment, I'm getting a copile error??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create User Defined Folder (Excel 2002)

    Say that the macro called by the button is named FolderMacro. It could look like this:

    Sub FolderMacro()
    Dim strFolder As String

    strFolder = GetFolderDlg
    If strFolder = "" Then
    MsgBox "You didn't select or create a folder!", vbExclamation
    Exit Sub
    End If

    ' Code to do something with the folder goes here.
    ...
    End Sub

    Where exactly do you get the compile error?

  5. #5
    Lounger
    Join Date
    Jan 2005
    Location
    Gwent, Wales
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create User Defined Folder (Excel 2002)

    Thanks for this........I don't get a compile error anymore, but I always get the message that I didn't create a folder etc. I have put the GetFolderDlg function in the VBA section "ThisWorkbook". Is this correct? The macro doesn't seem to be calling the function? Any ideas?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create User Defined Folder (Excel 2002)

    You should not put the GetFolderDlg function in ThisWorkbook, but in a standard module (the kind you create by selecting Insert | Module).

  7. #7
    Lounger
    Join Date
    Jan 2005
    Location
    Gwent, Wales
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create User Defined Folder (Excel 2002)

    Thanks Hans,

    This works really well. Thanks again <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •