Results 1 to 65 of 65

to insert picture and cropped to fit in the boxes

Threaded View

  1. #1
    Registered User
    Join Date
    03-08-2021
    Location
    singapore
    MS-Off Ver
    365
    Posts
    31

    to insert picture and cropped to fit in the boxes

    I am trying to insert pictures on active cells to create a picture report. however, as I go down the activesheet,i.e. row number increase, the picture keeps moving lower from the active cell I am trying to add the picture in. it doesn't also fit nicely in the boxes.
    In the picture report, I click on the green cell(picture1) and run the below code to insert the picture into the outlined box as per picture 2. the photos does not keep inside the outlined for the 2nd and 3rd picture, it is shifted down.

        Dim myPic As String
       
    
        ActiveSheet.Unprotect Password
         '   Get the filename & location of the picture
        myPic = Application.GetOpenFilename( _
            FileFilter:="Images (*.jpg;*.gif;*.png),*.jpg;*.gif;*.png", _
            Title:="Please select an image...")
            If myPic = "False" Then Exit Sub
         
        'Insert picture as Application.ActiveSheet.Shapes.AddPicture(filename, linktofile? FalseNo TrueYes, savewithdoc? TrueYes, Left, Top, Width, Height)'
        Set pic = Application.ActiveSheet.Shapes.AddPicture(myPic, False, True, 0, 0, -1, -1)
        'Set the range of the picture to be (start at active cell.Offset(down,right), activecell,Offset(increase height, increase width)'
        Set Rng = Range(ActiveCell, ActiveCell.Offset(13, 5))
            
            With pic
                .LockAspectRatio = False
                .Height = Rng.Height
                .Width = Rng.Width
                .Left = Rng.Left
                .Top = Rng.Top
    Capture2.JPG
    Capture.JPG
    Last edited by needhelp9009; 03-08-2021 at 02:32 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2021, 10:27 PM
  2. How to remove all inserted picture at one go?
    By Lewis Koh in forum Excel General
    Replies: 3
    Last Post: 02-24-2012, 12:06 PM
  3. picture replaced when new picture inserted in webpage
    By Webtekr in forum Word Formatting & General
    Replies: 1
    Last Post: 04-25-2009, 06:17 AM
  4. [SOLVED] Inserted picture name
    By DaveJones in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-08-2005, 10:40 AM
  5. [SOLVED] Inserted Picture - now there are copies of the picture in the spreadsheet
    By jkbob@optonline.net in forum Excel General
    Replies: 0
    Last Post: 11-14-2005, 12:25 AM
  6. [SOLVED] picture 34 was inserted by excel?
    By sophy2 in forum Excel General
    Replies: 1
    Last Post: 10-06-2005, 10:05 AM
  7. How to identify an inserted picture within a formula
    By Jeff Melvaine in forum Excel General
    Replies: 9
    Last Post: 01-30-2005, 09:06 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