我想在我的 excel 文件中添加更多文件。如果 multiselect 为 false,则此宏有效,但是如果我尝试使用 multiselect = true,则会在行中收到一条错误消息:
如果附件 = false 则退出子。错误消息是类型不匹配。
Sub insertObject()
Dim attachment As Variant
'open more files, but not from specific folder
attachment = Application.GetOpenFilename(FileFilter:="All Files (*.*), *.*", MultiSelect:=True)
'if attachment is missing then end macro
If attachment = False Then Exit Sub
'my try with OLEobjects
ActiveSheet.OLEObjects.Add(Filename:=attachment, Link:=False, DisplayAsIcon:=True, IconFileName:="C:\WINDOWS\system32\packager.dll", IconIndex:=1, IconLabel:=attachment).Select
End Sub