very nice. how do we make all pictures which we have uploaded 'in' cell instead of 'over' cell. also how to just get name of the image without the extension . Thanks in advance
Hi very helpfull thanks> how to add pictures 'in' cell instead of 'over' the cell? also how to just get the name of the file without the extension thanks in advance.
You cannot get "in" cell because pictures are shapes that are always over the elements of the worksheet. However, the video explains how to fit the picture within the cell borders.
One way is to add the list of names of those images that you want to add in a range maybe in other worksheet, and then add a condition inside the Do loop to check if the file has that name. You can check that adding another loop through the list of names (in the range or put into an array), or putting all of them into a string with Join and check if the file name is there with InStr. For that last option it would look like: If InStr(MyFile, TargetFiles) > 0 Then 'insert image where the TargetFiles string could be built with Join, for example for 10 image names in range A1:A10: TargetFiles = Join(Application.Transpose(Sheet2.Range("A1:A10").Value), ",") Another possibility is having the full name with path for the images you want to add and loop through the list while simply insert one a time. This way it doesn't matter if they are in the same folder or not, as long as you provide the path/folder info.
The picture fits the size of the cell. That's why we set the row height and then get the size first with properties Left, Top, Width, and Height. You can also set the column width of the cell before adding the picture with Cells(r, 2).ColumnWidth = 10 for example. If you want to change the width of the picture without changing the width of the cell (the picture will overflow the cell), you need to assign the picture to an object variable (Set pic = ActiveSheet.Shapes.AddPicture(myPic,msoFalse, msoTrue,x,y,....) and then modify the width with pic.Width = 200
This works for me. Thank you very much.
Excellent video
Thank you so much, Sir.
Thank you, helped so much today.
Was it possible to grab images from a subfolder in the folder we selected?
very nice.
how do we make all pictures which we have uploaded 'in' cell instead of 'over' cell.
also how to just get name of the image without the extension .
Thanks in advance
I already replied to this question above.
Hi very helpfull thanks>
how to add pictures 'in' cell instead of 'over' the cell?
also how to just get the name of the file without the extension
thanks in advance.
You cannot get "in" cell because pictures are shapes that are always over the elements of the worksheet. However, the video explains how to fit the picture within the cell borders.
How would I have only certain images inserted from the file folder selected?
One way is to add the list of names of those images that you want to add in a range maybe in other worksheet, and then add a condition inside the Do loop to check if the file has that name. You can check that adding another loop through the list of names (in the range or put into an array), or putting all of them into a string with Join and check if the file name is there with InStr. For that last option it would look like:
If InStr(MyFile, TargetFiles) > 0 Then 'insert image
where the TargetFiles string could be built with Join, for example for 10 image names in range A1:A10:
TargetFiles = Join(Application.Transpose(Sheet2.Range("A1:A10").Value), ",")
Another possibility is having the full name with path for the images you want to add and loop through the list while simply insert one a time. This way it doesn't matter if they are in the same folder or not, as long as you provide the path/folder info.
how can we make the width of the pictures bigger?
The picture fits the size of the cell. That's why we set the row height and then get the size first with properties Left, Top, Width, and Height. You can also set the column width of the cell before adding the picture with Cells(r, 2).ColumnWidth = 10 for example. If you want to change the width of the picture without changing the width of the cell (the picture will overflow the cell), you need to assign the picture to an object variable (Set pic = ActiveSheet.Shapes.AddPicture(myPic,msoFalse, msoTrue,x,y,....) and then modify the width with pic.Width = 200