maccten2000
Programmer
Hi All,
I have a report i am trying to automate. In essense it pulls data from MS Access, generates a pivot In Excel whose values i will then use to update several graphs all sitting behind a button.
I have encountered a problem i was wondering if you could help me with
The X-Axis on the graphs is variable depending on the information pulled back in the query. I cant seem to reference it in my code like i can the actual values. The code is being executed in Excel and its below (this is just a rough sketch) based off of someone elses code i found online
I was wondering if anyone has ever done anything like this before
Thanks for your time and i hope you have a good weekend
I have a report i am trying to automate. In essense it pulls data from MS Access, generates a pivot In Excel whose values i will then use to update several graphs all sitting behind a button.
I have encountered a problem i was wondering if you could help me with
The X-Axis on the graphs is variable depending on the information pulled back in the query. I cant seem to reference it in my code like i can the actual values. The code is being executed in Excel and its below (this is just a rough sketch) based off of someone elses code i found online
I was wondering if anyone has ever done anything like this before
Thanks for your time and i hope you have a good weekend
Code:
Dim oPPTApp As PowerPoint.Application
Dim oPPTShape As PowerPoint.Shape
Dim oPPTFile As PowerPoint.Presentation
Public oGraph As Graph.Chart
Dim SlideNum As Integer
Sub PPGraphMacro()
' Declare Variables
Dim strPresPath As String
Dim strExcelFilePath As String
Dim strNewPresPath As String
Dim oRange As Graph.Range
Dim strVal As String
' Set variables
strPresPath = "C:\Documents and Settings\user\Desktop\Automation\SI Compliance\SI Compliance.ppt"
strNewPresPath = "C:\Documents and Settings\user\Desktop\Automation\SI Compliance\SI Compliance_test.ppt"
Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)
SlideNum = 1
oPPTFile.Slides(SlideNum).Select
' Select First Graph
Set oPPTShape = oPPTFile.Slides(SlideNum).Shapes("Object 152")
Set oGraph = oPPTShape.OLEFormat.Object
' Loop through each cell until you get a null
With oGraph.Application.DataSheet
For Each oRange In .Range("a1:d1")
strVal = oRange.Value
Next oRange
End With
'oGraph.Application.DataSheet.Range("A1").Value = Cells(35, 3).Value
oGraph.Application.Update
oGraph.Application.Quit
oPPTFile.SaveAs strNewPresPath
oPPTFile.Close
oPPTApp.Quit
Set oGraph = Nothing
Set oPPTShape = Nothing
Set oPPTFile = Nothing
Set oPPTApp = Nothing
MsgBox "Presentation Created", vbOKOnly + vbInformation
End Sub