Adding Picture from Excel to PictureBox but empty picture show up

懵懂的女人 提交于 2019-12-12 02:58:43

问题


i have a code that add a group of several pictures. Then my program ran well on Win7 with Office 2010 that picturebox can show picture. But, when my program ran in WinXP with office 2003. It can't show any picture. Does anyone know why?

This is my code

For Each sp As EXCEL.Shape In xlsheet.Shapes
                    sp.Copy()
                    picname = sp.Name

                    If Strings.Left(picname, 5) = "Group" Then
                        If Clipboard.ContainsImage Then
                            MsgBox("have image")
                            xlPic = Clipboard.GetImage
                            PictureBox1.Image = xlPic
                            ImageList1.Images.Add(xlPic)
                        End If
                    End If
                    For Each Me.xlsheet In xlbook.Sheets
                        If xlsheet.Name.Equals("Reference") Then
                            xlsheet = xlapp.Sheets("Reference")
                            timerlamp.Enabled = True
                            For Each sp1 As EXCEL.Shape In xlsheet.Shapes
                                If Strings.Left(picname, 5) = "Group" Then
                                    sp1.Copy()
                                    If Clipboard.ContainsImage Then
                                        xlPic = Clipboard.GetImage
                                        ImageList1.Images.Add(xlPic)
                                    End If
                                End If
                            Next
                        Else
                            Exit For
                        End If
                    Next
                Next

来源:https://stackoverflow.com/questions/17266901/adding-picture-from-excel-to-picturebox-but-empty-picture-show-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!