Normally, in many excel working we require to add images inside sheets but most of times pictures dimensions are different. The situation gets worst when there are many pictures. With this code you can add many pictures quickly with same size. You can change size according to your requirements without adjusting size again and again.
- Create button by going into developer => Insert option
- Inside button copy below code.
ID = ActiveSheet.Cells(19, 7).ValueActiveSheet.Shapes.AddPicture _Filename:=ID, _linktofile:=msoFalse, savewithdocument:=msoCTrue, _Left:=ActiveSheet.Range("c5").Left, Top:=ActiveSheet.Range("c5").Top, Width:=ActiveSheet.Range("c5:d12").Width, Height:=ActiveSheet.Range("c5:d12").HeightActiveSheet.Range("c4:d12").Copy
- ID is complete address of image file
- With concatenate function you can create quick links for image selection
- Use concatenate function to combine Folder, File Name and Ext names togethher as per full path format.
- The image will be copied and resized on C5 to D12 cells.
Details of coding:
Shapes.AddPicture: Creates a picture from an existing file. Returns a Shape object that represents the new picture
FileName: The file from which the picture is to be created.
LinkToFile: The file to link to. Use msoFalse to make the picture an independent copy of the file.
SaveWithDocument: To save the picture with the document. Use msoFalse to store only the link information in the document. Use msoTrue to save the linked picture with the document into which it's inserted.This argument must be msoTrue if LinkToFile is msoFalse.
Watch Video tutorial Here
Subscribe YT: Computer Tech
Comments
Post a Comment