Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-15-2018, 09:16 AM
Kenneth Hobson Kenneth Hobson is offline macro: insert muliple images and resize into given cells Windows 10 macro: insert muliple images and resize into given cells Office 2016
Advanced Beginner
 
Join Date: Jun 2018
Posts: 37
Kenneth Hobson is on a distinguished road
Default

Welcome to the forum!

Automatic would mean that the macros are in the workbook and can act due to some event. If you want to keep the macro in your open workbook or personal workbook, then it would be run manually.

Since the height and widths have different ratios, did you really want to distort the image and make it fit? If you don't want to distort it, one would just set one of the dimensions.

As for the image file's name, what is the file extension? gif, jpg, bmp, png, etc.

It also makes a difference in coding if an image could already be in the image's cell. While one could overlay with another image, that is generally not done. So, more code is needed to avoid that problem.

Here is a simple example that may suit with a tweak or two. Change the offset from 1 to the offset you want, 13.
Code:
Sub Main()
  Dim pic As Shape, r As Range, fPath As String

  fPath = "x:\pics\"
  
  On Error Resume Next
  For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp))
    Set pic = ActiveSheet.Shapes.AddPicture(Filename:=fPath & r.Value2 & ".jpg", _
      LinkToFile:=msoFalse, SaveWithDocument:=msoCTrue, _
      Left:=r.Offset(, 1).Left, Top:=r.Offset(, 1).Top, _
      Width:=r.Width, Height:=r.RowHeight)
    'Debug.Print pic.Name
  Next r
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
macro: insert muliple images and resize into given cells Import images, resize them, and fit them to specific locations on the page hysterical.useless Drawing and Graphics 8 01-30-2018 04:27 PM
macro: insert muliple images and resize into given cells Complex VBA Code to Resize Alternating Images at the End of a Mail Merge macropodjr Mail Merge 5 09-11-2017 11:10 AM
macro: insert muliple images and resize into given cells Help Creating Macro to Crop/Resize Images ineedmacrohelp Word VBA 1 08-06-2015 06:46 AM
macro: insert muliple images and resize into given cells Help with VBA to resize images Yuffster Word VBA 2 01-30-2015 06:05 AM
Macro to Insert Text Into Cells Having Multiple Lines revans611 Excel Programming 4 10-24-2011 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft