• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Saving pictures from excel

GeorgeTsomaia

New Member
Hi,

I renamed images in excel, but when I extract them the names change like image01.
how can I extract them without losing the name?

George.
 
Hi,

Sorry but I don't understand what you wanted to say. In excel I renamed shapes with specific names. Now I need to extract images and them to have the same names which I asigned them.

George
 

Please avoid to quote each time the just previous post !

Unclear … Can you elaborate ?
 
I've named shapes in column B using a VBA code. Now I need to have those pictures on desktop and their names must be the same as I named them. I can't think of a solution.
 
Just follow logic :
when you extract an image, apply its name where it stands …

If the image within Excel was named with the correct name,
I can't foresee your issue …
 
I can't understand how to do it. Is there some kind of vba code or something?


▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
 

You can also activate the Macro Recorder and operate manually :
you will get a base code …
 
Names are in column A, images in column B
 

Attachments

  • პრაისი ბოთლები მილდიანი (დიდი)(2).xlsm
    97.1 KB · Views: 2
Try this code
Code:
Sub Test()
    Dim shp        As Picture
    Dim chrt        As ChartObject
    Dim n          As Long

    Application.ScreenUpdating = False
        On Error GoTo Finish
   
        For Each shp In ActiveSheet.Pictures
            n = n + 1
            Charts.Add.Location Where:=xlLocationAsObject, Name:=ActiveSheet.Name
            Set chrt = ActiveSheet.ChartObjects(1)
            chrt.Border.LineStyle = 0
            chrt.Width = shp.Width
            chrt.Height = shp.Height
            shp.Copy
           
            With chrt.Chart
                .ChartArea.Select
                .Paste
            End With
           
            chrt.Chart.Export Filename:=Cells(n + 2, 1) & ".jpg", FilterName:="jpg"
            chrt.Delete
        Next shp
    Application.ScreenUpdating = True
    Exit Sub
Finish:
End Sub
 
To the default Save location
You can change the path from this line
Code:
Filename:=Cells(n + 2, 1) & ".jpg"
Add the path before Cells .. Like that "C:\Temp\" & Cells .....
 
I have tested it and it worked for me
Code:
Sub Test()
    Dim shp        As Picture
    Dim chrt        As ChartObject
    Dim n          As Long

    Application.ScreenUpdating = False
        On Error GoTo Finish
 
        For Each shp In ActiveSheet.Pictures
            n = n + 1
            Charts.Add.Location Where:=xlLocationAsObject, Name:=ActiveSheet.Name
            Set chrt = ActiveSheet.ChartObjects(1)
            chrt.Border.LineStyle = 0
            chrt.Width = shp.Width
            chrt.Height = shp.Height
            shp.Copy
         
            With chrt.Chart
                .ChartArea.Select
                .Paste
            End With
         
            chrt.Chart.Export Filename:="C:\Temp\" & Cells(n + 2, 1) & ".jpg", FilterName:="jpg"
            chrt.Delete
        Next shp
    Application.ScreenUpdating = True
    Exit Sub
Finish:
End Sub

Create a folder on C: and name it "Temp"
Or change the path to suit your needs
 
Back
Top