May 10 2019 04:49 AM
Dear all
I've created an 'attach file'-button in my spreadsheet using the below macro.
I would however like for the icon of the attached file to be a generic green check mark instead of the excel.exe icon...
Can anyone help me modify the below macro to do that?
Br.
Robusfar
My macro:
Public Sub insertFile()
'Select the cell in which you want to place the attachment
Range("F11").Select
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
Filename:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub
Public Function extractFileName(filePath)
For i = Len(filePath) To 1 Step -1
If Mid(filePath, i, 1) = "\" Then
extractFileName = Mid(filePath, i + 1, Len(filePath) - i + 1)
Exit Function
End If
Next
End Function