How to bring picture in front in VBA

libelouli

New Member
Joined
Sep 30, 2018
Messages
8
Hello...
I'm using Excel 2010 and I have an issue with some pictures.
I load some pictures with the below code and I want to remove a specific one or bring in front the other one.
The problem is that any time I load a picture the excel name is different and I dont know a way to find that name to select it.
I use this code to load picture 1 :
Worksheets("R1").Shapes.AddPicture Folder(S) & "Screenshot_" & L & ".png", False, True, 5, Range("F" & T).Top, 580, 260

The path (S) is changing , also like name of file (Screenshot_1,etc) , also the cell that picture apears.
How I can find the name of the above picture to select it and delete it?
Also what is the code to bring this picture in front of other picture?
Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
When you put a picture you can name it using
Code:
selection.name="GiveName2Picture"
and bring it to front using
Code:
[LEFT][COLOR=#303336][FONT=Consolas]  Selection[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]ShapeRange[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]ZOrder [/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#303336][FONT=Consolas]msoBringToFront[/FONT][/COLOR][COLOR=#303336][FONT=Consolas])[/FONT][/COLOR][/LEFT]
 
Upvote 0
I have loaded more than one picture in excel and every time the name is changing i.ex Picture 250 or Picture 300.
How to determine which one is selected?
Wih the code : selection.name="GiveName2Picture" the only thing is doing is naming a specific cell is active that moment.Not the picture object.
 
Upvote 0
I thought you would name them when you download them using a specific method so that you can recall them later on using the same method...that is the only way. For example

Code:
    [COLOR=#008000]'You insert a picture that [/COLOR][COLOR=#008000][FONT=Verdana]excel names Picture123 [/FONT][/COLOR]    
ActiveSheet.Pictures.Insert("C:\Users\Kamolga\Pictures\MyTestingPhoto.jpg").Select 
    [COLOR=#008000]'You rename it on the spot[/COLOR]
    Selection.Name = "PictureToLaunchDashboard"
     [COLOR=#008000]' You do your code, and create other pictures that come on top of this one[/COLOR]
    [COLOR=#008000]'.....when you decide to bring that specific one on top:[/COLOR]
    ActiveSheet.Shapes.Range(Array("PictureToLaunchDashboard")).Select
    Selection.ShapeRange.ZOrder msoBringToFront

It could be that if you work with versions, you have a dynamic name (add an incrementing number to it) or simply have the last version named "MostRecent" and before inserting, you rename or delete "Most Recent" to give that name to the one you insert.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top