Displaying Excel chart image in Picturebox using VB.net

S

Stan

In the old days of VB6, an Excel chart image could be
pasted into a picture box with Clipboard using the
following commands.

xlApp.ActiveChart.ChartArea.Copy
Picture1.Picture = Clipboard.GetData()


I having problems doing this in VB.net? I tried the code
shown below, but it does not work. Its a modified version
of a Clipboard-bitmap example I found on the Microsoft
support site. I believe Excel Chart images copied onto
Clipboard as a enchanced metafile.

xlApp.ActiveChart.ChartArea.Copy

Dim oDataObj As IDataObject =
System.Windows.Forms.Clipboard.GetDataObject()

If Not System.Windows.Forms.Clipboard.GetDataObject() Is
Nothing Then

If oDataObj.GetDataPresent
(System.Windows.Forms.DataFormats.MetafilePict) Then
PictureBox1.Image = oDataObj.GetData
(DataFormats.EnhancedMetafile, True)
End If

End If


Please help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top