?
Solved

Save MSChart to a file

Posted on 2003-03-02
5
Medium Priority
?
343 Views
Last Modified: 2012-06-27
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?  
0
Comment
Question by:CheyenneSlim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 8052862
try this:

Private Sub Command1_Click()
MSChart1.EditCopy
Set Picture1.Picture = Clipboard.GetData(vbCFMetafile)
SavePicture Picture1.Picture, fname
End Sub
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8052866
or

Private Sub Command1_Click()
MSChart1.EditCopy
SavePicture Clipboard.GetData(vbCFMetafile), fname
End Sub
0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8052902
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
0
 
LVL 5

Expert Comment

by:Cimperiali
ID: 8052907
Emoreau told it correctly before me...
...give him the points!
0
 

Author Comment

by:CheyenneSlim
ID: 8053010
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question