N
Nick-B
Hi,
I have a spreadsheet which I have protected to stop people tampering
with it. As a result in order to add attachments to it I have included
a button and some VBA code. Now this all works fine, except the
attachment doesn't pick up the icon of the associated application (eg:
a word doc, etc), any thoughts on this would be appreciated, below is
the code, thanks:
Private Sub cmdInsert_Click()
Dim strFilename As String
Dim varNumber As Variant
Dim strPosition As String
strFilename = Application.GetOpenFilename(, , "Add Attachment")
If strFilename <> "False" Then
varNumber = InputBox("Enter attachment position number
(1 to 10)", "Add Attachement")
If varNumber >= 1 And varNumber <= 10 Then
strPosition = "D" & varNumber + 5
Range(strPosition).Select
ActiveSheet.OLEObjects.Add(Filename:=strFilename,
Link:=False, _
DisplayAsIcon:=True, *IconFileName:=strFilename*,
IconIndex:=0, _
IconLabel:=strFilename.Select End
If
End IfEnd Sub
I have a spreadsheet which I have protected to stop people tampering
with it. As a result in order to add attachments to it I have included
a button and some VBA code. Now this all works fine, except the
attachment doesn't pick up the icon of the associated application (eg:
a word doc, etc), any thoughts on this would be appreciated, below is
the code, thanks:
Private Sub cmdInsert_Click()
Dim strFilename As String
Dim varNumber As Variant
Dim strPosition As String
strFilename = Application.GetOpenFilename(, , "Add Attachment")
If strFilename <> "False" Then
varNumber = InputBox("Enter attachment position number
(1 to 10)", "Add Attachement")
If varNumber >= 1 And varNumber <= 10 Then
strPosition = "D" & varNumber + 5
Range(strPosition).Select
ActiveSheet.OLEObjects.Add(Filename:=strFilename,
Link:=False, _
DisplayAsIcon:=True, *IconFileName:=strFilename*,
IconIndex:=0, _
IconLabel:=strFilename.Select End
If
End IfEnd Sub