You can insert multiple objects in Excel, such as PDF, Word, Excel, and images, but only one object can be inserted at a time, in addition, it is complicated to display the icon and original name of the inserted object in Excel. Therefore, design a macro to solve this problem.
The following is the macro code:
Sub macro1 ()
'
'Macro1 macro
'
'Keyboard shortcut cut: Ctrl + m
'
Dim lngcount as long
Dim myfilepath as string
Dim myfilename as string
With application. filedialog (msofiledialogfilepicker) 'excel macro open file page design
. Allowmultiselect = true
. Show
For lngcount = 1 to. selecteditems. Count
'Msgbox. selecteditems (lngcount)
Myfilepath =. selecteditems (lngcount) 'sets the insert path
Myfilename = right (myfilepath, Len (myfilepath)-limit Rev (myfilepath, "\") 'sets the display name to the original inserted file name
'Msgbox (myfilepath)
Activesheet. oleobjects. Add (filename: = _
Myfilepath, link: = false, displayasicon: = _
True, iconfilename: = _
"C: \ WINDOWS \ Installer \ {AC76BA86-7AD7-1033-7B44-AB0000000001} \ pdffile_8.ico", _ 'show application icons
Iconindex: = 0, iconlabel: = myfilename). Select
Next lngcount
End
End sub
Using this macro, you can insert hundreds of files in excel at a time, which is very convenient.