Dr.Abdulwahab Al-anesi
asked on
Export pivot chart to power point
How to Export pivot chart from access 2003 or 2007 to power point
make that Me.ChartSpace......
Kelvin
Kelvin
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
ASKER
Kelvinspark;
I tried as below but did not work
Private Sub Command59_Click()
ChartSpace.ExportPicture "C:\Documents and Settings\aalanesi\Desktop\ " & DPTCoverageUtilizationPivo t & ".jpg", "JPEG"
End Sub
Can you correct if I am wrong
I tried as below but did not work
Private Sub Command59_Click()
ChartSpace.ExportPicture "C:\Documents and Settings\aalanesi\Desktop\
End Sub
Can you correct if I am wrong
Me.ChartSpace, not chartspace - was a typo on my part. This assumes the graph is on the same forms as the command button.
Kelvin
Kelvin
ASKER
Thanks Kelvin BUT It did not work May be there is a need of more details.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note their is a special section for pivot charts
Kelvin
Kelvin
ASKER
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_Pi vot_Cahrt. Form
frm.ChartSpace.ExportPictu re "C:\Documents and Settings\aalanesi\My Documents\Non Vaccine coverage PivotChart.jpg", "JPEG"
End Sub
Thanks to your support finally I succeeded I used the following to export a pivot named as Non_Vaccine_Coverage_Pivot
Private Sub Command25_Click()
Dim frm As Access.Form
Set frm = Me.Non_Vaccine_Coverage_Pi
frm.ChartSpace.ExportPictu
End Sub
Great
I should have given the initial line in the first place.
Kelvin
I should have given the initial line in the first place.
Kelvin
ASKER
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_Pi vot_Cahrt. Form
frm.ChartSpace.ExportPictu re "C:\Documents and Settings\aalanesi\My Documents\Non Vaccine coverage PivotChart.jpg", "JPEG"
End Sub
Private Sub Command25_Click()
Dim frm As Access.Form
Set frm = Me.Non_Vaccine_Coverage_Pi
frm.ChartSpace.ExportPictu
End Sub
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_Pi vot_Cahrt. Form
frm.ChartSpace.ExportPictu re 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.
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_Pi
frm.ChartSpace.ExportPictu
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
ASKER
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.
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.
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
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
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