VB6 插入图片到excel的指定的单元格中,调整图片大小后无法释放进程有关问题

VB6 插入图片到excel的指定的单元格中,调整图片大小后无法释放进程问题
我用vb6编写的程序,往excel指定单元格中插入图片,释放内存是可以的。但是加上调整图片大小,结果却无法释放内存了,应该怎么处理呢?


Private Sub Command2_Click()
    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlsheet As Excel.Worksheet
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
    Set xlBook = xlApp.Workbooks.Open("D:\temp\标签打印.xlsx")
    Set xlsheet = xlBook.Worksheets(1)
    xlsheet.Activate
    
    Clipboard.Clear
    Clipboard.SetData QRmaker1.Picture
    xlsheet.Range("D10").Select
    xlsheet.PasteSpecial Format:="位图", Link:=False, DisplayAsIcon:=False
    Selection.Top = xlsheet.Cells(10, 4).Top + 1
    Selection.Left = xlsheet.Cells(10, 4).Left + 1
    Selection.Width = xlsheet.Cells(10, 4).Width - 1
    Selection.Height = xlsheet.Cells(10, 4).Height - 1
    
    xlBook.ActiveSheet.PrintOut
    
    xlBook.Close (False)
    xlApp.Quit
    Set xlsheet = Nothing
    Set xlBook = Nothing
    Set xlApp = Nothing
End Sub
                                                  
        


------解决方案--------------------
假如excel中只有一个图片的话,你试试xlsheet.Shapes(1),代码如下:
xlsheet.Shapes(1).Top = xlsheet.Cells(10, 4).Top + 1
    xlsheet.Shapes(1).Left = xlsheet.Cells(10, 4).Left + 1
    xlsheet.Shapes(1).Width = xlsheet.Cells(10, 4).Width - 1
    xlsheet.Shapes(1).Height = xlsheet.Cells(10, 4).Height - 1
    这样应该可以正常关闭文件了。