我使用下面的代码将文件附加到Excel工作表中,它可以工作,但文件放在其他文件的顶部。如何在每个单元格中单独放置文件?
For Each elAtt In AttachList
Set MyAtt = Bug.Attachments.Item(elAtt.ID)
MyAtt.Load True, ""
'MsgBox MyAtt.Filename
ActiveSheet.Cells(i, 2).Value = MyAtt.Filename
ActiveSheet.Cells(i, 3).Value = MyAtt.Description
ActiveSheet.Cells(i, 4).Select
ActiveSheet.OLEObjects.Add Filename:=MyAtt.Filename, Link:=False, DisplayAsIcon:=False, Left:=40, Top:=40, Width:=20, Height:=10
'ActiveSheet.Cells(i, j).Value = Left(MyAtt.Filename, InStrRev(MyAtt.Filename, "\") - 1)
'theFileName = MyAtt.Filename
'thePath = Left(theFileName, InStrRev(theFileName, "\") - 1)
Set MyAtt = Nothing
i = i + 1
Next
答案 0 :(得分:0)
答案隐藏在代码的这一行结构中:
ActiveSheet.OLEObjects.Add Filename:=MyAtt.Filename, Link:=False, _
DisplayAsIcon:=False, Left:=40, Top:=40, Width:=20, Height:=10
引用Add method
的{{1}}语法:
OLEObjects collection
您需要更改expression.Add(ClassType, FileName, Link, _
DisplayAsIcon, IconFileName, IconIndex, IconLabel, Left, Top, Width, Height)
的{{1}}和Left
参数。解决方案如下:
Top