Results 1 to 7 of 7

EXCEL, PICTURE SHAPE, VBA: Fit Picture Proportionately Inside a Fixed Sized Picture Shape

Threaded View

lhasha EXCEL, PICTURE SHAPE, VBA:... 06-18-2016, 08:02 PM
AlphaFrog Re: EXCEL, PICTURE SHAPE,... 06-18-2016, 10:36 PM
lhasha Re: EXCEL, PICTURE SHAPE,... 06-18-2016, 10:54 PM
Kenneth Hobson Re: EXCEL, PICTURE SHAPE,... 06-18-2016, 11:03 PM
lhasha Re: EXCEL, PICTURE SHAPE,... 06-19-2016, 12:32 AM
Kenneth Hobson Re: EXCEL, PICTURE SHAPE,... 06-19-2016, 11:05 PM
lhasha Re: EXCEL, PICTURE SHAPE,... 06-20-2016, 10:02 PM
  1. #1
    Registered User
    Join Date
    04-12-2011
    Location
    San Jose, California
    MS-Off Ver
    Excel 2003
    Posts
    17

    EXCEL, PICTURE SHAPE, VBA: Fit Picture Proportionately Inside a Fixed Sized Picture Shape

    I am building a dashboard that allows for dynamic input and this includes adding and changing a signature image (gif format with transparent background)
    that will be used on multiple worksheets throughout the workbook using picture shapes. All picture shapes, including the primary on the dashboard
    (first sheet) are added using the following utility code at the time of constructing the form. Once the picture shape is added, the utility code is no
    longer necessary.

    Private Sub btnInitPicShape_Click()
    'THIS APPROACH IS USED INSTEAD OF SIMPLY ALLOWING THE USER TO LOAD THEIR FIRST PREFERRED SIGNATURE
    'IMAGE BECAUSE ***FOR SOME REASON*** THE FIRST IMAGE SELECTED AND LOADED INTO A PICTURE SHAPE REMAINS
    'AS A TOP LAYERED IMAGE NO MATTER WHAT SUBSEQUENT IMAGE IS SELECTED AND LOADED. UNTIL I FIND ANOTHER
    'SOLUTION, I HAVE OPTED TO ADD THIS UTILITY CODE AND ITS HOST BUTTON (LATER HIDDEN) TO EACH PERTINENT
    'SHEET. WHERE NECESSARY THIS CODE IS RUN TO ADD A SIGNATURE IMAGE.
    ActiveSheet.Shapes.AddPicture "C:\{path}\EmptyTransparent.gif", True, True, 100, 100, 215, 65
    End Sub



    The following code is what I use, for now, to allow the user to select and load their preferred signature image. It indeed does the job of loading the
    selected image however, and this is my problem with which I need help: I cannot find a way to size the signature image to fit within the picture shape
    (retaining the shape's size) but without distorting the image's in either the horizontal or vertical directions. In other words, I need the signatures
    to fit proportionately inside the statically sized and placed pictures shapes. Similar to the fmPictureSizeModeZoom setting for the PictureSizeMode for
    an ActiveX control.


    Sub Picture1_Click() ' ActiveSheet.'PICTURE 1' is the primary signature image
    Dim strFileToOpen
    strFileToOpen = Application.GetOpenFilename(Title:="Select GIF Signature File", FileFilter:="GIF Files *.gif* (*.gif*),")

    '(ADD FILE VALISATION ERROR HANDLING CODE HERE)

    'GET SIGNATURE FILE (TRANSPARENT GIF)
    With ActiveSheet.Shapes("Picture 1").Fill
    .Visible = msoTrue
    .UserPicture strFileToOpen
    .TextureTile = msoFalse
    End With
    'POPULATE SIGNATURE IMAGE ON SAME SHEET
    With ActiveSheet.Shapes("Picture 2").Fill
    .Visible = msoTrue
    .UserPicture strFileToOpen
    .TextureTile = msoFalse
    End With
    'POPULATE SIGNATURE IMAGE ON A DIFFERENT SHEET
    With Sheets("Sheet2").Shapes("Picture 1").Fill
    .Visible = msoTrue
    .UserPicture strFileToOpen
    .TextureTile = msoFalse
    End With

    End Sub


    I would very much appreciate any assistance or advise in regards to this issue.

    Regards,
    Last edited by lhasha; 06-18-2016 at 08:12 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vba excel to change shape fill from existing picture in another worksheet
    By cookiedesire in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2016, 02:47 AM
  2. VBA code to set PICTURE shape attribute other than .name
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2015, 10:48 AM
  3. Changing a Picture's Shape
    By Shleifer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2014, 07:25 PM
  4. Changing a Picture's Shape
    By Shleifer in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-10-2014, 02:18 PM
  5. [SOLVED] deleting picture (shape)
    By TimlmiT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2014, 10:13 AM
  6. Adding Picture to Shape
    By ando185 in forum Excel General
    Replies: 0
    Last Post: 06-25-2013, 03:27 PM
  7. Shape/picture name in a worksheet
    By neta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2006, 11:00 AM

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