Adding Picture from Excel to PictureBox but empty

2019-08-30 00:35发布

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

0条回答
登录 后发表回答