+ Reply to Thread
Results 1 to 7 of 7

Resize icon representing embedded object using VBA

  1. #1
    Registered User
    Join Date
    01-15-2010
    Location
    So. Cal. USA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Resize icon representing embedded object using VBA

    I have icons representing inserted embedded objects and I want to use VB to resize them because I am using VB to create them. After they have been created I can right-click on them and select 'Format Object' then go to the Size tab and manually tweek the scale so the icon fits in the cell nicely. This is the op I want to automate as well in VB.
    The help files in Excel are virtually worthless. I hope MS is listening. Thank you for your help and thank God for the internet.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Resize icon representing embedded object using VBA

    Welcome to the forum.

    You haven't provided enough information for anyone to help.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Resize icon representing embedded object using VBA

    Hello NateofCA,

    Here is an example. It uses a single cell as the destination for the embedded icon. The icon is then re-sized to match the cell's dimensions. You will need to include the icon's name. he example here uses "Object 1".
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    01-15-2010
    Location
    So. Cal. USA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Resize icon representing embedded object using VBA

    Thanks for your replies. Here is the code I use to locate a pdf file and insert it as an object with icon displayed

    Public Sub btnAddFile()
    Dim vFile As Variant
    vFile = Application.GetOpenFilename("All Files,*.pdf", Title:=" Find file to insert")
    If LCase(vFile) = "false" Then Exit Sub
    ActiveSheet.OLEObjects.Add Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconFileName:="C:\WINDOWS\Installer\{AC76BA86-1033-0000-BA7E-100000000002}\PDFFile.ico", IconIndex:=0, IconLabel:="Plot"

    End Sub


    I fiddled around with the code given by Leith and couldn't figure out how to get it to work. I'm not sure what the icon name would be in my case. It seems like I might be able use something like the line below and that's what I'm checking out now

    ActiveCell.FormatConditions.AddIconSetCondition

    I put it within the same code loop right after when the file gets inserted. Seems I need to add the properties such as Leith gave.
    Thanks.
    Last edited by NateofCA; 01-16-2010 at 01:03 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Resize icon representing embedded object using VBA

    Nate, please take a few minutes to read the Forum Rules, and then edit your post to wrap your code with Code Tags.

    Thanks.

  6. #6
    Registered User
    Join Date
    01-15-2010
    Location
    So. Cal. USA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Resize icon representing embedded object using VBA

    OK Let's see if I get this right this time. Here's the code again. Thanks.

    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Resize icon representing embedded object using VBA

    Hello NateofCa,

    Here is your code with my code added in.
    Please Login or Register  to view this content.

+ 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