Sekiranya anda ingin mengeksport dengan cepat semua lampiran gambar e-mel Outlook ke lembaran kerja Excel, anda boleh merujuk artikel ini. Di sini kami akan menunjukkan cara yang lebih berkesan daripada mengeksport secara manual.
Apabila anda menerima e-mel yang mengandungi pelbagai lampiran gambar, jika anda ingin menggunakannya untuk membuat laporan dalam Excel, anda pasti ingin mencari cara untuk mengeksport imej-imej ini ke dalam lembaran kerja Excel secara berkumpulan. Sekarang, kami akan memperkenalkan pendekatan sedemikian kepada anda seperti berikut.

Eksport Semua Lampiran Imej E-mel ke Lembaran Kerja Excel
- Sebagai permulaan, akses aplikasi Outlook anda dengan cara biasa.
- Kemudian, di tetingkap Outlook, tekan pintasan kekunci "Alt + F11", yang akan memunculkan tetingkap "Microsoft Visual Basic for Applications".
- Di skrin ini, anda perlu membuka modul yang tidak digunakan atau memasukkan yang baru secara lurus.
- Seterusnya, anda harus menyalin potongan kod VBA di bawah ke dalam modul ini.
Sub ExportAllImageAttachmentsToExcelWorksheet()
Dim objSourceMail As Outlook.MailItem
Dim objAttachment As Outlook.Attachment
Dim strImage As String
Dim objExcelApp As Excel.Application
Dim objExcelWorkbook As Excel.Workbook
Dim objExcelWorksheet As Excel.Worksheet
Dim objFile As Object
Dim objFiles As Object
Dim nRow As Integer
Select Case Outlook.Application.ActiveWindow.Class
Case olInspector
Set objSourceMail = ActiveInspector.currentItem
Case olExplorer
Set objSourceMail = ActiveExplorer.Selection.Item(1)
End Select
If Not (objSourceMail Is Nothing) Then
'Save the image attachments to a temporary folder
strTempFolder = Environ("Temp") & "\" & Format(Now, "yyyymmddhhmmss") & "\"
MkDir (strTempFolder)
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
For Each objAttachment In objSourceMail.Attachments
If IsEmbedded(objAttachment) = False Then
Select Case LCase(objFileSystem.GetExtensionName(objAttachment.filename))
Case "jpg", "jpeg", "png", "bmp", "gif"
objAttachment.SaveAsFile strTempFolder & objAttachment.filename
End Select
End If
Next
'Create a new Excel workbook
Set objExcelApp = CreateObject("Excel.Application")
Set objExcelWorkbook = objExcelApp.Workbooks.Add
Set objExcelWorksheet = objExcelWorkbook.Sheets(1)
objExcelApp.Visible = True
objExcelWorkbook.Activate
'Get the images in the temporary folder
Set objFiles = objFileSystem.GetFolder(strTempFolder).Files
'Insert the images into this new Excel worksheet
For Each objFile In objFiles
strImage = strTempFolder & Trim(objFile.Name)
nRow = nRow + 1
With objExcelWorksheet
.Range("A" & nRow).value = objFile.Name
'Change the height and width as per your needs
.Range("B" & nRow).ColumnWidth = 10
.Range("B" & nRow).RowHeight = 80
.Range("B" & nRow).Activate
With .Pictures.insert(strImage)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 50
.Height = 70
End With
End With
.Columns("A").AutoFit
.Activate
End With
Next
End If
End Sub
Function IsEmbedded(objCurAttachment As Outlook.Attachment) As Boolean
Dim objPropertyAccessor As Outlook.propertyAccessor
Dim strProperty As String
Set objPropertyAccessor = objCurAttachment.propertyAccessor
strProperty = objPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E")
If InStr(1, strProperty, "@") > 0 Then
IsEmbedded = True
Else
IsEmbedded = False
End If
End Function
- Selepas itu, anda boleh keluar dari makro.
- Kemudian, menuju ke "File"> "Options"> "Quick Access Toolbar" untuk menambahkan makro ini ke Quick Access Toolbar.
- Akhirnya, anda boleh mencuba makro ini sekarang.
- Pertama, pilih atau buka e-mel sumber.
- Kemudian, klik butang makro di Bar Alat Akses Pantas.
- Apabila makro selesai, anda akan mendapat lembaran kerja Excel, ditunjukkan seperti tangkapan skrin berikut:
Lindungi Fail Outlook daripada Rosak
Telah diketahui bahawa Outlook terdedah kepada rasuah. Oleh itu, kita harus memahami bagaimana melindungi kerosakan bentuk Outlook. Pertama, untuk menyekat serangan virus, perlu memasang perisian antivirus dan jangan sekali-kali memuat turun lampiran yang tidak diketahui. Selain itu, lebih baik kita menggunakan alat pembaikan yang kuat, seperti DataNumen Outlook RepairIa boleh menawarkan ubat yang paling berkesan sekiranya berlaku Rasuah Outlook.
Pengenalan Pengarang:
Shirley Zhang adalah pakar pemulihan data di DataNumen, Inc., yang merupakan pemimpin dunia dalam teknologi pemulihan data, termasuk pemulihan sql dan produk perisian pembaikan prospek. Untuk maklumat lebih lanjut, lawati www.datanumen.com

