Macro to Export Chart to Word or JPG (to <SteveT>)

W

Wim De Preter

Hey Steve (or...)

I tried your macro to export a (pivot)chart to a jpg-
format, but in compiling there was a problem with the
name of "Chart1".

I have a form called "Formulier1", and it is the Chart -
in Pivotchartview - that I would like to export in jpg-
format. But I can't find the exact name for this
pivotchart.

So how exactly do you find the name for "Graph1"?

Many thanks in advance

Wim

Ps: this was SteveT's macro

Private Sub cmdExport_Click()

Dim strFile As String
strFile = InputBox("Please Enter a valid path and file
name (ie:
c:\temp\graph.jpg)", "Save As?", "c:\temp\graph.jpg")

Dim gObj As Object
'the graph in this example is named "Graph1"
Set gObj = Me.Graph1.Object
gObj.Export strFile, "JPEG" ' "GIF" also available
Set gObj = Nothing
Me.Graph1.Action = acOLEClose
End Sub
 
W

Wim De Preter

Hi Steve

Thanks a lot for the advice, the macro works well.

Wim
-----Original Message-----
See MsKb 304171 for some good clues as to the answer:

This code will save the Pivot Chart to a file, you'll have to make it
pretty...

Private Sub Form_Activate()
'You'll need a reference to Office Web Components to get Intellisense
'I had to use late binding to make it run...

Dim objPivotChart As Object 'OWC.WCChart
Dim objChartSpace As Object 'OWC.ChartSpace
Dim frmChart As Access.Form

Set frmChart = Me
Set objChartSpace = frmChart.ChartSpace
Set objPivotChart = objChartSpace.Charts.Item(0)

'Set type of chart to a 3D Column.
objPivotChart.Type = chChartTypePie
objChartSpace.ExportPicture "c:\temp\pivot.gif", "GIF",
300, 500
 

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