标题:VB6 提取excel 中的图片无法显示
只看楼主
zhgfeng20
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2020-8-13
结帖率:100%
 问题点数:0 回复次数:0 
VB6 提取excel 中的图片无法显示
用以下命令从Excel 中提取的图片,不能显示,每次不显示的图片编号还不一样。求高手指教。谢谢。

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = CreateObject("Excel.Application")
        xlApp.Visible = True
        Dim a(1 To 6) As String
        Dim b(1 To 20) As String
        Dim n As Integer
        a(1) = "1-1"
        a(2) = "1-2"
        a(3) = "2-1"
        a(4) = "2-2"
        a(5) = "3-1"
        a(6) = "3-2"
        b(1) = "0001"
        b(2) = "0002"
        b(3) = "0003"
        b(4) = "0004"
        b(5) = "0005"
        b(6) = "0006"
        b(7) = "0007"
        b(8) = "0008"
        b(9) = "0009"
        b(10) = "0010"
        b(11) = "0011"
        b(12) = "0012"
        n = 1
        For j = 1 To 12
               For i = 1 To 6
                    Set xlBook = xlApp.Workbooks.Open("C:\Users\HG\Desktop\Temp1\" & b(i) & "\" & a(i))
                    Set xlSheet = xlBook.Worksheets(1)
                    xlSheet.Activate
                    Clipboard.Clear  
                    xlSheet.Shapes(1).Copy
                     Image1.Picture = Clipboard.GetData   
                     SavePicture Image1, "C:\Users\HG\Desktop\Temp2\" & n & ".jpg"
                     n = n + 1
                     xlBook.Close
                     xlApp.Quit
                     Set xlSheet = Nothing
                     Set xlBook = Nothing
                     set xlApp=nothing
                     
             Next i
       Next j
      
    xlApp.Quit
    Set xlSheet = Nothing
    Set xlBook = Nothing
    set xlApp=nothing
   
End Sub
搜索更多相关主题的帖子: excel Dim 图片 Nothing Set 
2020-08-23 19:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502941-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.159894 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved