?
Solved

Export pivot chart to power point

Posted on 2010-01-11
15
Medium Priority
?
1,357 Views
Last Modified: 2012-05-08
How to Export pivot chart from access 2003 or 2007 to power point
0
Comment
[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
  • 8
  • 5
15 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26281348
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26281351
make that Me.ChartSpace......
 
Kelvin
0
 
LVL 2

Expert Comment

by:rajvihari
ID: 26281461
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:Dr.Abdulwahab Al-anesi
ID: 26281501
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26281514
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
 

Author Comment

by:Dr.Abdulwahab Al-anesi
ID: 26282100
Thanks Kelvin BUT It did not work May be there is a need of more details.
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 2000 total points
ID: 26282260
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26282263
Note their is a special section for pivot charts
Kelvin
0
 

Author Comment

by:Dr.Abdulwahab Al-anesi
ID: 26300478
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26302436
Great
 
I should have given the initial line in the first place.
 
Kelvin
0
 

Author Comment

by:Dr.Abdulwahab Al-anesi
ID: 26304343
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26308022
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
 

Author Comment

by:Dr.Abdulwahab Al-anesi
ID: 26344017
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
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 26344332
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

Independent Software Vendors: 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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

765 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