| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1282 人关注过本帖
标题:VB6 提取Excel 中图片,提取出的图片无法显示
只看楼主 加入收藏
zhgfeng20
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2020-8-13
结帖率:100%
收藏
 问题点数:0 回复次数:1 
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\Huaguo\Desktop\Temp2\" & n & ".jpg"
                     n = n + 1
                     xlBook.Close
                     xlApp.Quit
             Next i
       Next j
      
    xlApp.Quit
    Set xlSheet = Nothing
    Set xlBook = Nothing
   
End Sub
搜索更多相关主题的帖子: 图片 提取 Excel Set Dim 
2020-08-18 11:07
zhgfeng20
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2020-8-13
收藏
得分:0 
已解,在循环前加 set xlapp= nothing 就可以了
2020-08-18 12:56
快速回复:VB6 提取Excel 中图片,提取出的图片无法显示
数据加载中...
 
   



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

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