How to insert multiple objects (PDF, Word, Excel, image, etc.) in Excel)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.