vb6.0 打开一个存在的excel文件后插入一张.jpg图片
vb6.0 在一个按钮单击事件中 打开已存在的excel文件后插入一张.jpg图片。想实现这个功能
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\111.xls")
Set xlSheet = xlBook.Worksheets(1)
网上好多代码用到 "xlSheet.Pictures.Insert("C:\123.jpg")"
可是 xlSheet 下没有 pictures 呀。。。。
请问各位高手,关于在excel中插入图片的功能怎么实现呀 Excel Visual?Basic?6.0 图片
[解决办法]
'先引用对象库:Microsoft Excel 11.0 Object Library
Option Explicit
Dim xlExcel As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Private Sub Command1_Click()
On Error GoTo Errhandler
xlExcel.Application.Visible = True
Me.MousePointer = vbHourglass
xlExcel.Workbooks.Add
xlExcel.Workbooks(1).Activate
Set xlSheet = xlExcel.Workbooks(1).Worksheets(1)
xlSheet.Activate
ActiveSheet.Pictures.Insert("C:\WINDOWS\Zapotec.bmp").Select
Errhandler:
Exit Sub
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
xlBook.Close
xlExcel.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlExcel = Nothing
End Sub