• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

Export pivot chart to power point

How to Export pivot chart from access 2003 or 2007 to power point
0
Dr.Abdulwahab Al-anesi
Asked:
Dr.Abdulwahab Al-anesi
  • 8
  • 5
1 Solution
 
Kelvin SparksCommented:
The simplest way is to export the chart to a jpeg, then embed it into Powerpoint.
 
You can use code such as
.ChartSpace.ExportPicture "C:\Documents and Settings\Paul\Desktop\" & varName & ".jpg", "JPEG"  to export the desktop for use Paul (varName would have been a unique filename assigned via a txtbox for the graph.
 
Kelvin
0
 
Kelvin SparksCommented:
make that Me.ChartSpace......
 
Kelvin
0
 
rajvihariCommented:
Hi, Here I gives one solution for export p'chart, but you have to place it in PPT manually...
Private Function ExportMyCharts() As Boolean
Const Path_SavedChart As String = "C:\"
Dim i As Long
Dim objSht As Worksheet

Set objSht = ThisWorkbook.Sheets(1)

If objSht.ChartObjects.Count < 1 Then
    ExportMyCharts = False
    Exit Function
Else
    ExportMyCharts = True
    For i = 1 To objSht.ChartObjects.Count
        objSht.ChartObjects(i).Chart.Export Path_SavedChart & "\" & i & ".gif"
    Next
End If
End Function

Open in new window

0
Technology Partners: 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!

 
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Kelvinspark;
I tried as below but did not work
Private Sub Command59_Click()

ChartSpace.ExportPicture "C:\Documents and Settings\aalanesi\Desktop\" & DPTCoverageUtilizationPivot & ".jpg", "JPEG"
End Sub

Can you correct if I am wrong
0
 
Kelvin SparksCommented:
Me.ChartSpace, not chartspace - was a typo on my part. This assumes the graph is on the same forms as the command button.
 
Kelvin
0
 
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Thanks Kelvin BUT It did not work May be there is a need of more details.
0
 
Kelvin SparksCommented:
Have a look at this
http://support.microsoft.com/kb/824276/en-us
I based my code around this, but what I gave you was from an adp I developed and that tends to behave a little differently.
Kelvin
0
 
Kelvin SparksCommented:
Note their is a special section for pivot charts
Kelvin
0
 
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Dear Kelvin

Thanks to your support finally  I succeeded I used the following to export a pivot named as Non_Vaccine_Coverage_Pivot_Cahrt

Private Sub Command25_Click()
 Dim frm As Access.Form

    Set frm = Me.Non_Vaccine_Coverage_Pivot_Cahrt.Form
    frm.ChartSpace.ExportPicture "C:\Documents and Settings\aalanesi\My Documents\Non Vaccine coverage PivotChart.jpg", "JPEG"
End Sub
0
 
Kelvin SparksCommented:
Great
 
I should have given the initial line in the first place.
 
Kelvin
0
 
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Te code be low works in my PC bout not in other PCs,  What I should change to make the picture be exported to My Document folder of the current user?  

Private Sub Command25_Click()
 Dim frm As Access.Form

    Set frm = Me.Non_Vaccine_Coverage_Pivot_Cahrt.Form
    frm.ChartSpace.ExportPicture "C:\Documents and Settings\aalanesi\My Documents\Non Vaccine coverage PivotChart.jpg", "JPEG"
End Sub
0
 
Kelvin SparksCommented:
I suspect the path to My Documents is failing, as it may well be hard coded to your name.
 
In a code module create the following lines
Declare Function SHGetFolderPath Lib "shfolder.dll" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwReserved As Long, ByVal lpszPath As String) As Long
Private Const MY_DOCUMENTS& = &H5
Private Const MY_PICTURES& = &H27
Private Const HWND_CURRENT_WINDOW& = &H0
Then copy in the two functions in the code below
 
Then, in your form, use
Private Sub Command25_Click()
 Dim frm As Access.Form

Dim MyDocs As String
''Find the location of My Documents
MyDocs = GetFolderPath(MY_DOCUMENTS)  
    Set frm = Me.Non_Vaccine_Coverage_Pivot_Cahrt.Form
    frm.ChartSpace.ExportPicture MyDocs & "\Non Vaccine coverage PivotChart.jpg", "JPEG"
End Sub
 
Kelvin
 
Note, I got the functions etc from some other place in EE a year or so back when doing a similar project.


 

Private Function TrimNull(startstr As String) As String
   Dim i As Integer
   Dim char As String
   For i = Len(startstr) To 1 Step -1
      char = Mid$(startstr, i, 1)
      If Asc(char) = 0 Then
         TrimNull = Mid(startstr, 1, i - 1)
      End If
   Next
End Function

Private Function GetFolderPath(folder As Long) As String
   'declarations
   Dim buff As String
   
   'fill buffer with the specified folder item
   buff = Space$(256)
   If SHGetFolderPath(-1, folder, -1, &H27, buff) = 0 Then
      GetFolderPath = TrimNull(buff)
   End If
End Function

Open in new window

0
 
Dr.Abdulwahab Al-anesiProjects Information Technology ManagerAuthor Commented:
Dear Kelvin
I could not use or understand your last comments, can we keep in touch till we resolve it
What should I do to make it exported to any current user my document.

Or opt them to select the destination folder.
0
 
Kelvin SparksCommented:
My last comment was code to return to you the path of the logged in users My Documents.
A simpler solution would be to have a common folder that all could use, that does not have their name in it (i.e. C:\GraphExport\)
It would be fairly simple to check that it exists, if not create it the export to it.
What's your thoughts on that?
Kelvin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now