我正在使用作为答案here提供的脚本将文件上传到Excel文档。如何指定文件图标的显示位置?实际上,图标会自动显示在我已将VBA脚本分配给的按钮上。
答案 0 :(得分:1)
选择您需要显示图标的单元格
说row = 10,col = 10
ActiveSheet.Cells(10,10)。选择'这将集中所需的单元格
ActiveSheet.OLEObjects.Add(Filename:= fullFileName,Link:= _ False, DisplayAsIcon:= True,IconFileName:= _ iconToUse,IconIndex:= 0, IconLabel:= fullFileName)。选择
答案 1 :(得分:0)
试试这个:
Dim fn As String, sht as Worksheet
fn = "C:\Users\fffffffff\Desktop\tester.xlsx"
Set sht = ActiveSheet
With sht.OLEObjects.Add(Filename:=fn, Link:=False, DisplayAsIcon:=True)
.Left = sht.Range("E5").Left
.Top = sht.Range("E5").Top
End With