CheyenneSlim
asked on
Save MSChart to a file
How can I save an MSChart graph to a file? I have tried all manner of methods using the ClipBoard and the RichTextBox. I need to send a copy of the graph in an email, either in the body or as an attachment.
When I try to capture the MSChart by calling EditCopy, in the program it always returns a number about 10 digits long. It is a different number every time (sometimes negative) and has no relationship to the data in the graph. Yet, when I pause the code after calling the EditCopy and launch Word, the behavior of the manual paste is correct
Clipboard.Clear
MSChart1.EditCopy
For I = 1 To 100000
DoEvents
If Clipboard.GetFormat(8) = True Then
Exit For
End If
Next
Open fname For Output As #ff
Print #ff, Clipboard.GetData(8)
The file contains this value: -804975683
I am obviously missing something. What its it?
When I try to capture the MSChart by calling EditCopy, in the program it always returns a number about 10 digits long. It is a different number every time (sometimes negative) and has no relationship to the data in the graph. Yet, when I pause the code after calling the EditCopy and launch Word, the behavior of the manual paste is correct
Clipboard.Clear
MSChart1.EditCopy
For I = 1 To 100000
DoEvents
If Clipboard.GetFormat(8) = True Then
Exit For
End If
Next
Open fname For Output As #ff
Print #ff, Clipboard.GetData(8)
The file contains this value: -804975683
I am obviously missing something. What its it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
B ecause the graph is a picture, and the number you get is the handle of that picture.
To save it to a file, you can save ii as a BMP file the following way, as suggested from MSDN:
Private Sub Command1_Click()
MSChart1.EditCopy
SavePicture Clipboard.GetData, "c:\test1.bmp"
End Sub
To save it to a file, you can save ii as a BMP file the following way, as suggested from MSDN:
Private Sub Command1_Click()
MSChart1.EditCopy
SavePicture Clipboard.GetData, "c:\test1.bmp"
End Sub
Emoreau told it correctly before me...
...give him the points!
...give him the points!
ASKER
Thanks!
Private Sub Command1_Click()
MSChart1.EditCopy
SavePicture Clipboard.GetData(vbCFMeta
End Sub