復制代碼 代碼如下:
Dim im as Image=Image.FromFile ("C:/picture.bmp") '獲得Image
System.Windows.Forms.Clipboard.SetDataObject(im, True) '復制到剪貼板
Dim xlApp As Excel.Application = New Excel.Application()
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlBook = xlApp.Workbooks().Add
xlSheet = xlBook.Worksheets("sheet1")
Dim range As Excel.Range = xlSheet.Range(xlApp.Cells(4, 1), xlApp.Cells(4, 1)) '粘貼圖片的位置
xlSheet.Paste(range, im) '將圖片插入Excel