Solved Export graph (1 Viewer)

amir0914

Registered User.
Local time
Today, 11:32
Joined
May 21, 2018
Messages
151
Hi everyone,
I created a graph by a query on a form and now it shows only the graph, How can I print the graph or form, or export to pdf?? (Horizontally)
Screenshot (1848).png

Thanks in advanced.
 

June7

AWF VIP
Local time
Today, 10:32
Joined
Mar 9, 2014
Messages
5,488
Can export graph to jpg file with:

Private Sub btnExport_Click()
Dim graphExp As Object
Set graphExp = Me.MyGraphName
graphExp.Export "C:\images\Graph.jpg", "jpg"
End Sub

At least, it might work. I certainly thought it did for me at one time but now it is not working nicely.

Otherwise, build a report and print report or export report to pdf.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:32
Joined
May 7, 2009
Messages
19,247
you can PrintScreen the Form.
 

amir0914

Registered User.
Local time
Today, 11:32
Joined
May 21, 2018
Messages
151
Can export graph to jpg file with:

Private Sub btnExport_Click()
Dim graphExp As Object
Set graphExp = Me.MyGraphName
graphExp.Export "C:\images\Graph.jpg", "jpg"
End Sub

At least, it might work. I certainly thought it did for me at one time but now it is not working nicely.

Otherwise, build a report and print report or export report to pdf.
Thank you June7, but it gives this error after run the code:
Screenshot (1849).png


Code:
Dim graphExp As Object
Set graphExp = Me.Graph0
graphExp.Export "C:\Graph.jpg", "jpg"
 

June7

AWF VIP
Local time
Today, 10:32
Joined
Mar 9, 2014
Messages
5,488
Sorry I even showed you the code. It's been a long time since I first tried it and forgot the issues it has. After running the code I get errors even trying to close the form. "The operation on the chart object failed. The OLE server may not be registered. To register the OLE server, reinstall it." I also get this error when I try to use OLEObject controls. Think I started getting this error after a Windows update. The jpg doesn't even capture the entire graph.

The error you get usually means there is a missing library reference, but as far as I can remember, I did not set any library reference for this code.

Might web search the Export method and see what you can find if you are really interested in it. That's how I originally found this code.
 

June7

AWF VIP
Local time
Today, 10:32
Joined
Mar 9, 2014
Messages
5,488
Also, since the code uses late binding, special library reference should not be needed. I tested the code in a new db without adding library references and get same result.
 

Users who are viewing this thread

Top Bottom