Results 1 to 23 of 23

VBA Picture insert from directoy in merged cell and scaling

Threaded View

heinzpol VBA Picture insert from... 02-13-2020, 11:12 AM
PCI Re: VBA Picture insert from... 02-13-2020, 06:39 PM
heinzpol Re: VBA Picture insert from... 02-14-2020, 03:46 AM
PCI Re: VBA Picture insert from... 02-14-2020, 05:25 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 06:58 AM
PCI Re: VBA Picture insert from... 02-14-2020, 07:10 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 07:49 AM
PCI Re: VBA Picture insert from... 02-14-2020, 08:00 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 08:21 AM
PCI Re: VBA Picture insert from... 02-14-2020, 08:31 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 08:37 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 10:00 AM
PCI Re: VBA Picture insert from... 02-14-2020, 10:07 AM
heinzpol Re: VBA Picture insert from... 02-14-2020, 12:42 PM
PCI Re: VBA Picture insert from... 02-14-2020, 12:50 PM
heinzpol Re: VBA Picture insert from... 02-14-2020, 01:17 PM
PCI Re: VBA Picture insert from... 02-14-2020, 02:27 PM
heinzpol Re: VBA Picture insert from... 02-15-2020, 04:32 AM
PCI Re: VBA Picture insert from... 02-15-2020, 07:40 AM
heinzpol Re: VBA Picture insert from... 02-15-2020, 08:49 AM
PCI Re: VBA Picture insert from... 02-15-2020, 09:48 AM
Zappatustra Re: VBA Picture insert from... 10-20-2022, 03:43 AM
PCI Re: VBA Picture insert from... 10-20-2022, 04:53 AM
  1. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: VBA Picture insert from directoy in merged cell and scaling

    A remake
    in a module put
    Option Explicit
    
    Sub Treat()
    Dim WkPath As String
    WkPath = ActiveWorkbook.Path & "\" & "Pictures"
     
    Dim PicRg  As Range
        Set PicRg = Range("MyPicture")
    Dim WkPicN As String
    WkPicN = Range("I13")
    Dim WkPic As Picture
    Dim H, W
    
    Dim WkRg As Range
        Application.ScreenUpdating = False
        With ActiveSheet
            For Each WkPic In .Pictures
                Set WkRg = .Range(WkPic.TopLeftCell.Address & ":" & WkPic.BottomRightCell.Address)
                If Not Intersect(WkRg, PicRg) Is Nothing Then WkPic.Delete
            Next
        End With
    
        
        Set WkPic = ActiveSheet.Pictures.Insert(WkPath & "\" & WkPicN & ".jpg")
    '   Resize picture
        With WkPic
            .ShapeRange.LockAspectRatio = msoTrue
             W = PicRg.Cells(1, 1).Width + PicRg.Cells(1, 2).Width + PicRg.Cells(1, 3).Width
             H = PicRg.Cells(1, 1).Height + PicRg.Cells(2, 1).Height + PicRg.Cells(3, 1).Height
            .Height = 0.95 * H
            .Left = PicRg.Left + (W - .Width) / 2
            .Top = PicRg.Top + (H - .Height) / 2
            
     '       .Width = (PicRg.Cells(1, 1).Width + PicRg.Cells(1, 2).Width + PicRg.Cells(1, 3).Width)
     '       .Height = (PicRg.Cells(1, 1).Height + PicRg.Cells(2, 1).Height + PicRg.Cells(3, 1).Height)
        End With
        Application.ScreenUpdating = True
    
    End Sub
    in the sheet's code put


    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If (Target.Address <> Range("I13").Address) Then Exit Sub
        Call Treat
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Hyperlink cell values to pdf file in a directoy
    By mubashir aziz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2017, 07:52 AM
  2. Resize picture to fit merged cell
    By TitansGo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-29-2016, 04:20 PM
  3. [SOLVED] Insert Picture in cell, click commanbutton to rename picture, lock cell and remove button
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2014, 10:05 PM
  4. [SOLVED] import picture to fit in merged cell
    By alexshaw76 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2014, 09:35 PM
  5. Import picture to fit in merged cell
    By alexshaw76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 03:37 PM
  6. VBA for Picture insert at particular worksheet range. Picture name derived from cell.
    By Douglas2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2013, 01:16 AM
  7. [SOLVED] How do i insert a picture in merged cels, with autom. resizing ?
    By Sven Ghyselinck in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-27-2006, 04:30 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