Results 1 to 17 of 17

Embed and resize object with Macro/VBA

Threaded View

  1. #1
    Registered User
    Join Date
    08-16-2013
    Location
    West Coast USA
    MS-Off Ver
    Excel 2019/365
    Posts
    12

    Embed and resize object with Macro/VBA

    I found this very old post and it is almost exactly what I want... However there is one minor change I'm after.
    here... /excel-programming-vba-macros/714267-resize-icon-representing-embedded-object-using-vba (I would make this a proper link -- but you all don't trust me with that much power)

    I trust you :-)
    https://excelforum.com/excel-program...using-vba.html
    --6StringJazzer

    well, there were a couple of changes, but I figured them out. What remains is I don't like the icon it gives. If I manually resize the object I end up with an icon that looks like a minuature of the document. With the macro, I didn't. I tried just deleting the icon file name (see code below), but that gives me a white square. What I would like is what I thought was the default.

    Also, tried to include pic... as this is one of those cases where a picture would definately be worth 1000 words, but again not allowed for new users. Looks like it did allow the image after all... First icon is if done manually, 2nd is with the code from the above referenced thread, 3rd icon is what I am getting with code posted below.

    ' embed file
    ' resize_embedded_object Macro
    '
    
    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
    
        With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
          .Left = ActiveCell.Left
          .Top = ActiveCell.Top
          .Height = ActiveCell.Height
        End With
        
    End Sub
    Attached Images Attached Images
    Last edited by SL_Accounting; 08-05-2022 at 07:03 PM. Reason: add solved tag

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Embed Google Chrome Object into Userform
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2015, 07:06 PM
  2. [SOLVED] Macro to add an embedded object and resize to certain dimensions
    By Eamster in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2013, 12:41 PM
  3. Embed a object in Excel
    By Nikhilgupta in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-11-2012, 02:14 AM
  4. EMBED image was resize every time after print all worksheet
    By p008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2012, 10:37 PM
  5. embed a word object
    By stevesunfold in forum Excel General
    Replies: 1
    Last Post: 10-16-2008, 02:18 PM
  6. [SOLVED] How do I embed an object into a specific cell in Excel?
    By fish in forum Excel General
    Replies: 0
    Last Post: 06-15-2005, 08:05 AM
  7. [SOLVED] How can I embed a file as an unopened object in a worksheet or wo.
    By Goat Boy in forum Excel General
    Replies: 2
    Last Post: 01-04-2005, 08:06 PM

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