Attachements and Hyperlinks in an Excel UserForm (HOW TO)

Yonex1975

New Member
Joined
Jan 23, 2014
Messages
3
I have created an Excel UserForm that I am using to track employee coaching documentation and the Action Planning process. I am wanting to know how to create an option to select and upload and attachment, have it saved to a Shared Drive on our network then create a link that would be on the Excel Data sheet that can be clicked to retrieve the document?

Is this possible? If so, how?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Yes it's possible, but you should really be using Access, not Excel. The basic premise is something like this:

Rich (BB code):
Sub test()

    Const sharedPath    As String = "\\server\share\"
    Dim filepath        As String
    Dim filename        As String
       
    filepath = Application.GetSaveAsFilename
    
    If Len(filepath) > 0 Then
        filename = Split(filepath, "\")(UBound(Split(filepath, "\")))
        FileCopy filepath, sharedPath & filename
    End If
    
    MsgBox sharedPath & filename
    
End Sub

But there's more to consider, what if someone uploads a document that has the same name as another? The code will overwrite it, this is probably not what you want (though it might be). The usual way of doing this therefore is to save files using GUIDs, that way you won't end up overwriting anything, but you will need to maintain a record of which guid has which friendly name, you may also want to store some metadata, such as who saved it. You can then have friendly links with meaningful filenames without worrying about whether someone has uploaded a document with the same name as another.

An alternative approach may be to check if the file already exists in the folder and rename it if it does, the issue with this is that it can get slow and you may end up with conflicts should there be many files and multiple people uploading at the same time. It also adds additional code and complexity.
 
Upvote 0
Thank you for the information.
To answer you question, I am just now attempting my first project like this and am not familiar with Access but I will look into it.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top