DSMD1984
12-14-2016, 09:10 AM
Hi all,
Hopefully someone can assist me.
I've created an employee database using Excel VBA and am stuck with something.
I'm able to add an attachment to an employee profile, which embeds the file in their column (Row FL), on the spread sheet, however I'm now not sure how to display or access that attachment from the userform, without opening the spread sheet.
Here's the code I've used to add the attachment.
Private Sub CommandButton16_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("***Database").Range("A" & row_number)
If item_in_review = ComboBox1.Text Then
Sheets("***Database").Range("FL" & row_number).Select
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
ActiveSheet.OLEObjects.Add _
Filename:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:=".exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
MsgBox "Attachment Saved!", , "PLEASE NOTE"
End If
Loop Until item_in_review = ""
End Sub
What would I use on the userform to then display the attachments on the userform?
Hopefully someone can help.
Thank you.
Hopefully someone can assist me.
I've created an employee database using Excel VBA and am stuck with something.
I'm able to add an attachment to an employee profile, which embeds the file in their column (Row FL), on the spread sheet, however I'm now not sure how to display or access that attachment from the userform, without opening the spread sheet.
Here's the code I've used to add the attachment.
Private Sub CommandButton16_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("***Database").Range("A" & row_number)
If item_in_review = ComboBox1.Text Then
Sheets("***Database").Range("FL" & row_number).Select
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
ActiveSheet.OLEObjects.Add _
Filename:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:=".exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
MsgBox "Attachment Saved!", , "PLEASE NOTE"
End If
Loop Until item_in_review = ""
End Sub
What would I use on the userform to then display the attachments on the userform?
Hopefully someone can help.
Thank you.