View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nick-B Nick-B is offline
external usenet poster
 
Posts: 1
Default Icons for attachments added via VBA


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


--
Nick-B
------------------------------------------------------------------------
Nick-B's Profile: http://www.excelforum.com/member.php...o&userid=37267
View this thread: http://www.excelforum.com/showthread...hreadid=569810