Skip i'r prif gynnwys

Sut i allforio pob delwedd ar unwaith o Excel?

Gan dybio bod gennych lawer o luniau yn eich llyfr gwaith a'ch bod am eu cadw i ffolder penodol ar y tro, fel arfer gallwch gopïo a gludo'r lluniau fesul un â llaw i'w cadw, ond mae'n cymryd llawer o amser i'w copïo a'u gludo dro ar ôl tro fel hyn. Yma, byddaf yn cyflwyno rhai awgrymiadau i chi ar gyfer datrys y swydd hon.


Allforiwch yr holl ddelweddau ar unwaith o Excel gyda swyddogaeth Save As

Gyda'r Excel wedi'i ymgorffori Save As swyddogaeth, gallwch arbed llyfr gwaith fel Web Page i gadw'r holl luniau gan gynnwys siartiau, siapiau a gwrthrychau eraill mewn ffolder. Gwnewch fel a ganlyn.

1. Agorwch y llyfr gwaith gyda'r lluniau rydych chi am eu cadw. Cliciwch Ffeil > Save As > Porwch.

2. Yn y Save As blwch deialog, mae angen i chi:

2.1) Dewiswch ffolder i gadw'r delweddau a allforiwyd;
2.2) Dewiswch Web Page o'r gwymplen Cadw fel math;
2.3) Cliciwch y Save botwm.

3. Yn y popping up Microsoft Excel blwch deialog, cliciwch y Ydy botwm.

4. Agorwch y ffolder lle mae'r ffeiliau wedi'u hallforio yn cael eu cadw a gallwch weld ffolder a ffeil fformat HTML a restrir y tu mewn. Mae'r holl luniau yn y llyfr gwaith gan gynnwys siartiau, siapiau neu wrthrychau yn cael eu cadw yn y ffolder hwn.

5. Gallwch gadw'r lluniau sydd eu hangen arnoch yn y ffolder a dileu eraill nad oes eu hangen arnoch


Allforio'n hawdd Pob Delwedd Ar Unwaith O Excel Gyda theclyn anhygoel

Bydd y dull uchod yn tynnu pob gwrthrych o'r llyfr gwaith, efallai, rhai ohonynt nad oes eu hangen arnoch chi. Os oes gennych chi Kutools ar gyfer Excel gosod yn Excel, ei Graffeg Allforio efallai y bydd nodwedd yn eich helpu i arbed y lluniau sydd eu hangen arnoch yn unig.

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel a ganlyn:

1. Cliciwch Kutools Byd Gwaith > Mewnforio ac Allforio > Graffeg Allforio:

2. Yn y Graffeg Allforio blwch deialog, ffurfweddwch fel a ganlyn:

2.1) Dewiswch lluniau oddi wrth y Mathau rhestr ostwng;
Awgrym: Yn ddiofyn, rhestrir yr holl graffeg gan gynnwys siartiau, lluniau a siapiau yn y llyfr gwaith cyfredol.
2.2) Yn y Cadw cyfeiriadur adran, cliciwch ar botwm i ddewis ffolder i arbed eich lluniau allforio;
2.3) Yn y Fformat allforio rhestr gwympo, dewiswch y math o ddelwedd rydych chi am ei hallforio fel;
2.4) Cliciwch OK.

3. Yna mae blwch deialog yn ymddangos i ddweud wrthych faint o luniau sydd wedi'u hallforio'n llwyddiannus, cliciwch ar y OK botwm.

Nawr gallwch chi fynd i'r ffolder cyrchfan a gwirio'r delweddau a allforiwyd.

Cliciwch Graffeg Allforio i wybod mwy am y nodwedd hon.

Cyn gwneud cais Kutools ar gyfer Excel, os gwelwch yn dda ei lawrlwytho a'i osod yn gyntaf.


Allforio delweddau a'u hail-enwi gyda'r gwerthoedd celloedd cyfagos

Fel y dangosir yn y screenshot isod, mae dwy golofn, un yn cynnwys rhestr o enwau ffrwythau a'r llall yn cynnwys y lluniau cyfatebol o'r ffrwythau. I allforio'r delweddau hyn a'u henwi'n awtomatig gyda'r enwau ffrwythau cyfatebol, gallwch roi cynnig ar y cod VBA yn yr adran hon.

1. Yn y daflen waith lle rydych chi am allforio'r lluniau, pwyswch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwl. Ac yna copïwch y VBA canlynol i ffenestr y Modiwl.

Cod VBA: Allforio lluniau mewn colofn a'u henwi'n awtomatig

Sub ExportImages_ExtendOffice()
'Updated by Extendoffice 20220308
    Dim xStrPath As String
    Dim xStrImgName As String
    Dim xImg As Shape
    Dim xObjChar As ChartObject
    Dim xFD As FileDialog
    Set xFD = Application.FileDialog(msoFileDialogFolderPicker)
    xFD.Title = "Please select a folder to save the pictures" & " - ExtendOffice"
    If xFD.Show = -1 Then
       xStrPath = xFD.SelectedItems.Item(1) & "\"
    Else
        Exit Sub
    End If
    
    On Error Resume Next
    For Each xImg In ActiveSheet.Shapes
        If xImg.TopLeftCell.Column = 2 Then
        xStrImgName = xImg.TopLeftCell.Offset(0, -1).Value
        If xStrImgName <> "" Then
            xImg.Select
            
            Selection.Copy
            Set xObjChar = ActiveSheet.ChartObjects.Add(0, 0, xImg.Width, xImg.Height)
            With xObjChar
                .Border.LineStyle = xlLineStyleNone
                .Activate
                ActiveChart.Paste
                .Chart.Export xStrPath & xStrImgName & ".png"
                .Delete
            End With
        End If
        End If
    Next
End Sub

Nodiadau:

1) Y rhif 2 yn y llinell “Os xImg.TopLeftCell.Column = 2 YnaMae ” yn cynrychioli rhif y golofn yr ydych am allforio'r lluniau ohoni;
2) Y rhif -1 yn y llinell “xStrImgName = xImg.TopLeftCell.Offset(0, -1).Gwerth” yn nodi y byddwch yn enwi'r lluniau gyda gwerthoedd y celloedd chwith cyfagos.

3. Gwasgwch y F5 allwedd i redeg y cod. Yn y ffenestr sy'n agor, dewiswch ffolder i arbed y lluniau ac yna cliciwch OK.

Yna mae'r holl luniau mewn colofn benodol yn cael eu hallforio a'u henwi'n awtomatig gyda'r gwerthoedd celloedd cyfagos fel y nodwyd gennych.


Erthygl gysylltiedig:

Sut i allforio siartiau i graffeg yn Excel?

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (24)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
WaW Amazing ! Thanks a lot ! It works perfect for me !
I couldn't insert Milan's code inside the first one, so maybe you could update with the two codes combined ?
It is because my pictures are so small...
Rated 5 out of 5
This comment was minimized by the moderator on the site
Thank you! The code does the job. The only downside is it exports images in displayed size, not in original size. And it's often the case, when an otherwise large image is scaled down to fit in the cell. Is there a way to tweak this code to export original size images?

Sub ExportImages_ExtendOffice()
'Updated by Extendoffice 20220308
    Dim xStrPath As String
    Dim xStrImgName As String
    Dim xImg As Shape
    Dim xObjChar As ChartObject
    Dim xFD As FileDialog
    Set xFD = Application.FileDialog(msoFileDialogFolderPicker)
    xFD.Title = "Please select a folder to save the pictures" & " - ExtendOffice"
    If xFD.Show = -1 Then
       xStrPath = xFD.SelectedItems.Item(1) & "\"
    Else
        Exit Sub
    End If
    
    On Error Resume Next
    For Each xImg In ActiveSheet.Shapes
        If xImg.TopLeftCell.Column = 2 Then
        xStrImgName = xImg.TopLeftCell.Offset(0, -1).Value
        If xStrImgName <> "" Then
            xImg.Select
            
            Selection.Copy
            Set xObjChar = ActiveSheet.ChartObjects.Add(0, 0, xImg.Width, xImg.Height)
            With xObjChar
                .Border.LineStyle = xlLineStyleNone
                .Activate
                ActiveChart.Paste
                .Chart.Export xStrPath & xStrImgName & ".png"
                .Delete
            End With
        End If
        End If
    Next
End Sub
This comment was minimized by the moderator on the site
same issue...
just a quick edit:
If xStrImgName <> "" Then
            xImg.Select
          [b]  xImg.ScaleHeight 1#, True, msoScaleFromTopLeft
            xImg.ScaleWidth 1#, True, msoScaleFromTopLeft[/b]


this will resize all images, so you have to close the file afterwards without saving to preserve the initial vie, but the pictures will go out in their original size.
This comment was minimized by the moderator on the site
fixed, thank you anyway:

Sub ExportImages_ExtendOffice()
'Updated by Extendoffice 20220308
    Dim xStrPath As String
    Dim xStrImgName As String
    Dim xImg As Shape
    Dim xObjChar As ChartObject
    Dim xFD As FileDialog
    Set xFD = Application.FileDialog(msoFileDialogFolderPicker)
    xFD.Title = "Please select a folder to save the pictures" & " - ExtendOffice"
    If xFD.Show = -1 Then
       xStrPath = xFD.SelectedItems.Item(1) & "\"
    Else
        Exit Sub
    End If
    
    On Error Resume Next
    For Each xImg In ActiveSheet.Shapes
        If xImg.TopLeftCell.Column = 2 Then
        xStrImgName = xImg.TopLeftCell.Offset(0, -1).Value
        If xStrImgName <> "" Then
            xImg.Select
'            Selection.Copy
            Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
            Set xObjChar = ActiveSheet.ChartObjects.Add(0, 0, xImg.Width, xImg.Height)
            With xObjChar
                .Parent.ShapeRange.Line.Visible = msoFalse
                .Border.LineStyle = xlLineStyleNone
'                .Activate
                .Select
                ActiveChart.Paste
                .Chart.Export xStrPath & xStrImgName & ".png"
                .Delete
            End With
        End If
        End If
    Next
End Sub
This comment was minimized by the moderator on the site
Thank you for this great tool, It saved me a ton of time. But I've ran into an issue that most of the photos are saved as blank photos as shown in the attached screenshot. Appreciate the help. Thank you
This comment was minimized by the moderator on the site
Hello, Mohamed
Did your problem occur when using Kutools for Excel? If so, could you upload your workbook file here if you don't mind?
So that, we can check where the problem is?
Thank you!
This comment was minimized by the moderator on the site
I am using the code given in the " Export images and rename them with the adjacent cell values" part of the article. When I run this code I get the following error: "Run-time error '91': Object variable or With block variable not set."

When I click "debug" it points me to line 9 of the code :
xFD.Title = "Please select a folder to save the pictures" & " - ExtendOffice"

Do you have a solution to this? Your article is the only solution I can find.

I am using Excel for Mac.
This comment was minimized by the moderator on the site
Hello, Dylan,

Sorry, our code is only applicable to Microsoft Excel, maybe you can try the code in Microsoft Excel.
Thank you!
This comment was minimized by the moderator on the site
I am using Microsoft Excel on Mac OSX.
This comment was minimized by the moderator on the site
I am also getting this issue using a Mac - Dylan were you able to resolve?

Are we meant to change something with the below that it is picking up as a bug?

xFD.Title = "Please select a folder to save the pictures" & " - ExtendOffice"
This comment was minimized by the moderator on the site
Hello, thank you for this article. When I execute the code above from Export images and rename them with the adjacent cell values, I get the following error message: Run-time error '91': Object variable or With block variable not set. When I click debug, it highlights line 9 of the code. Do you know why this is happening? FYI I am using Excel for Mac OSX. Thank you
This comment was minimized by the moderator on the site
Τέλειο εργαλείο! Όμως το μέγεθος-ανάλυση της εικόνας μικραίνει . Υπάρχει τρόπος να διατηρηθεί η αρχική ανάλυση ?
This comment was minimized by the moderator on the site
Bonjour le code VBA m'enregistre des images blanches je ne comprends pas pourquoi. quelqu'un a une solution ?
This comment was minimized by the moderator on the site
Hello, Sophie,
The code in this article can work well in my Excel, could you upload your Excel file here if you don't mind? So we can help to check the problem for you.
Or you can describe your problem more clear and detailed.
Thank you!
This comment was minimized by the moderator on the site
hallo skyyang, ich habe seit neulich das gleiche problem, viele leere *.png dateien.
Your text to link
bei jedem exportversuch werden andere bilder nicht richtig erfasst.
mfg und danke
This comment was minimized by the moderator on the site
Hello, milan bojic
Which Excel version do you use?
I have tried the code in your workbook, it works well, and all the images in your workbook are exported in the folder and renamed based on the cell value, see screenshot:
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-export-images-1.png
This comment was minimized by the moderator on the site
Hello skyyang, it's office 365. your code was working fine until 2 weeks ago, not anymore, see screenshot. meanwhile i found something similar that works, (combined with yours), maybe you can use that for your code.

screenshot:
[img]https://drive.google.com/file/d/1vfRlhpyzqg7QNFeYl53mTvNON3gIrFwv/view?usp=sharing[/img]


Sub BilderExportieren()
    Dim shaBild As Shape
    Dim strZielpfad As String
    strZielpfad = "c:\Tuerliste\img3\" '<== Zielpfad entsprechend anpassen!!
    For Each shaBild In ActiveSheet.Shapes
        BildExportShape shaBild, strZielpfad
    Next shaBild
End Sub

Sub BildExportShape(shaBild As Shape, strZiel As String)
    Dim xStrImgName As String
    Dim chDiagramm As ChartObject
    xStrImgName = shaBild.TopLeftCell.Offset(0, -1).Value
    Application.ScreenUpdating = False
    shaBild.CopyPicture Appearance:=xlScreen, Format:=xlPicture
    Set chDiagramm = ActiveSheet.ChartObjects.Add(0, 0, shaBild.Width, shaBild.Height)
    With chDiagramm.Chart
        ' erforderlich bei Excel2010, da Diagrammfläche automatisch mit Rahmen erstellt wird
        .Parent.ShapeRange.Line.Visible = msoFalse
        ' bei Excel2016 muss die Diagrammfläche selektiert vor .Paste werden - andernfalls ist das Bild leer
        If Val(Application.Version) = 16 Then .ChartArea.Select
        .Paste
        .Export Filename:=strZiel & xStrImgName & ".png", FilterName:="png"
    End With
    chDiagramm.Delete
    Set chDiagramm = Nothing
    Set shaBild = Nothing
    Application.ScreenUpdating = True
End Sub


Thank you anyway
Milan Bojic
This comment was minimized by the moderator on the site
Hello, milan bojic,
Thanks for your code, maybe it can help others in the future. 🙂
This comment was minimized by the moderator on the site
This is great, if I wanted to grab the background colour of a cell (instead of an image) and save that as a image named with the adjacent cell how would that be an easy change to the code?
This comment was minimized by the moderator on the site
Hi Tom,Do you mean saving the background color of the cell as an image and named it with the adjacent cell value?Sorry can't help you with that.
This comment was minimized by the moderator on the site
thanks a lot it helped me a lot
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations