Rename image after inserting

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
Office Version
  1. 2019
Platform
  1. Windows
I'm using this code to insert an image to my sheet from my local drive. However, I can't seem to rename the image. The third line is suppose to rename the image, but after the image is inserted, its not selected. Therefore the image is not being renamed. Can someone help.. Thank you

VBA Code:
Sub Macro1()
ActiveSheet.Shapes(Application.Caller).TopLeftCell.Select
ActiveSheet.Pictures.Insert ActiveCell.Comment.Text
Selection.Name = ActiveCell.Value
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Found my answer...

VBA Code:
ActiveSheet.Pictures(ActiveSheet.Pictures.Count).Name
 
Upvote 0
I know I can resize the image using the PictureSizeMode, but the image quality is diminished. How can i resize the picture without diminishing the image quality?
I have a code that exports a chart to the computer and then loads the chart to a userform, but having a difficult time adapting it to an image.

VBA Code:
Dim MyChart As Chart
Dim FName As String

Set Wks = ActiveSheet

Set MyChart = Wks.Shapes("chGrade").Chart
FName = VBA.Environ("TEMP") & Application.PathSeparator & "MyChart.jpg"
MyChart.Export FName
Image1.Picture = LoadPicture(FName)
Kill FName
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,755
Members
448,989
Latest member
mariah3

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