+ Reply to Thread
Results 1 to 2 of 2

EMBEDDING / ATTACHING OBJECTS INTO EXCEL 2010 - Missing OLE Object icon???

Hybrid View

  1. #1
    Registered User
    Join Date
    10-15-2012
    Location
    Birmingham
    MS-Off Ver
    Excel 2010
    Posts
    3

    EMBEDDING / ATTACHING OBJECTS INTO EXCEL 2010 - Missing OLE Object icon???

    Hello All,

    FYI: Using EXCEL 2010

    I am still learning VBA so I am still not 100% on exactly where I might be going wrong with this so I am hoping it is a simple fix??? I am looking to attach objects into an EXCEL worksheet and I have gotten as far as the following: (It is connected to a command button)
    Private Sub CommandButton1_click()
    
    Dim vFile As Variant
    
    vFile = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
    
    If LCase(vFile) = "false" Then Exit Sub
    ActiveSheet.OLEObjects.Add(Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconFilename:=vFile, IconIndex:=0, IconLabel:=vFile).Select
    
    End Sub
    My current issues are:

    1. The code works fine HOWEVER the OLE icon image is missing - what am I doing wrong?
    2. The code will attach multiple files of any type HOWEVER the objects are sat on top of each other - what can I do to determine a 'target' for each object (MAX 3 per section needed)

    As I said I am a novice so apologies if this is a simple fix but we all have to start somewhere - I look forward to your replies!
    Last edited by JosephP; 03-05-2013 at 11:33 AM. Reason: add code tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: EMBEDDING / ATTACHING OBJECTS INTO EXCEL 2010 - Missing OLE Object icon???

    use shapes.addoleobject and skip the icon arguments
    Private Sub CommandButton1_click()
    
    Dim vFile As Variant
    
    vFile = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
    
    If LCase(vFile) = "false" Then Exit Sub
    ActiveSheet.Shapes.AddOLEObject Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile, Left:=Range("A1").Left, Top:=Range("A10").Top, Width:=10, Height:=20
    
    End Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1