Consulting

Results 1 to 8 of 8

Thread: Copy file from source path in cell, to destination path in cell, and create folders

  1. #1
    VBAX Regular
    Joined
    Mar 2023
    Posts
    28
    Location

    Copy file from source path in cell, to destination path in cell, and create folders

    Good morning,

    I hope you are all well.

    I am having extremely bad luck with my coding just lately, I am very much a beginner and a copy & paste expert (I'm not afraid to admit it).

    I have hit a brick wall though.

    Basically the company I work for needs me to create a portal in excel where managers can save files of their employees to their 'employee file'.

    So I have made a sheet where they can select which file they want to save, which then generates a path in which the file will be saved to.

    The issue I have is that I need the path to generate the associated folders (which will be their name), so then I do not need to add a new folder each time a new employee starts, this folder will automatically be created in the destination folder when they submit the file, which is then saved in the newly created folder.

    Could anybody help me with this?

    Any help you could provide would be greatly appreciated.

    2023-03-29 11_17_13-Copy file from source path in cell, to destination path in cell, and create .jpg

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    Welcome to the VBAX forum eclaid.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    can you attach a sample excel file?

  4. #4
    VBAX Regular
    Joined
    Mar 2023
    Posts
    28
    Location
    Hi guys,

    Thank you for your reply and your welcome.

    Please see below:

    https://file.io/ShoUB71z3ptH


    Thanks.

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    Below is a small sub that checks if a folder exists, if not then it will create it:
    Sub MakeMyFolder()
        Dim fPath As String
        
        fPath = "C:\Users\JoeBloggs\Desktop\TEST\George"
        
        If Dir(fPath, vbDirectory) = "" Then
            MkDir Path:=fPath
            MsgBox "Done"
        Else
            MsgBox "found it"
        End If
    End Sub
    Or another option:
    Sub MakeMyFolder2()
        Dim fPath As String
        Dim fsoFSO
        
        fPath = "C:\Users\clarkg\Desktop\TEST\George"
        
        Set fsoFSO = CreateObject("Scripting.FileSystemObject")
        If fsoFSO.FolderExists(fPath) Then
            MsgBox "found it"
        Else
            fsoFSO.CreateFolder (fPath)
            MsgBox "Done"
        End If
    End Sub
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  6. #6
    you may also try this.
    Attached Files Attached Files

  7. #7
    VBAX Regular
    Joined
    Mar 2023
    Posts
    28
    Location
    Wow! Thank you guys so much. This is exactly what I've needed.

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    ecalid, if you are happy with the solution please use the Thread Tools Option and select "Mark thread as Solved" ( to the top right of the very first post in this thread)
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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