Hello,
I have been tasked with updating (always fun) an old Access to Powerpoint Visual Basic program from Office 2003 to 2007. I am running into a problem where I get an error when trying to access the OLEFormat of slides the program has generated. The error I get is, "OLEFormat (unknown member): Invalid request. This property only applies to OLE objects."
The code is paraphrased (I do not include it all as the subroutine is 34 pages long) as follows:
Function CreateGraph(CGFF_Tablename as string, objPPPres as PowerPoint.Presentation..........etc.)
Dim oDatasheet as Object
Dim lRowCnt as Long
Dim currDB as DAO.Database
Dim Rec_Set as DAO.Recordset
Dim CGFF_field as DAO.Field
Dim pptGraph as Graph.Chart
Dim intCnt as Integer
Dim intRecCnt as Integer
' Does a bunch of stuff to set up the chart tables
' Loop through all of th eslides for this report type.
For intSlideCnt = 1 to intNumSlides
intFieldCnt = 1
int ShpCnt = 0
' If need to start a new slide
If (intRecCnt = 0) and (lFowCnt<intNumRows) Then
' Add a new slide
Set objPPSlide = AddNewSlide(objPPPres, ppLayoutTitleOnly, strSlideTitle)
pptGraph.Application.Update
DoEvents
End If
'add the graph
Set pptGraph=objPPSlide.Shapes.AddOLEObject(Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight-50, ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
' More processing goes on here repeating the creation of slides several times. Now to get the scale on the slides all the same.
' If there were more than one slide for this report
if intNumSlides > 1 then
if pptGraph.Axes(xlValue).MaximumScale>intMaxScale then
intMaxScale=pptGraph.Axes(xlValue).MaximumScale
End If
Set pptGraph=Nothing
' Loop through all of the slides for this report and update the maximum scale
For intCnt=intStartSlideNum to intSlideNum
********This is the line that is failing********
Set pptGraph = objPPPres.Slides(intCnt).Shapes(2).OLEFormat.Object
With pptGraph
.Axes(xlValue).MaximumScale = intMaxScale
.Axes(xlValue).MinimumScale = 0
End With
Set pptGraph = Nothing
Next intCnt
End If
' More processing
End
Blame any typo's in the above code on me. It compiles just fine. I had to transcribe it by hand.
Any insight into why this procedure, which works fine in 2003 by the way, fails now would be helpful.
Thank you,
Paul
I have been tasked with updating (always fun) an old Access to Powerpoint Visual Basic program from Office 2003 to 2007. I am running into a problem where I get an error when trying to access the OLEFormat of slides the program has generated. The error I get is, "OLEFormat (unknown member): Invalid request. This property only applies to OLE objects."
The code is paraphrased (I do not include it all as the subroutine is 34 pages long) as follows:
Function CreateGraph(CGFF_Tablename as string, objPPPres as PowerPoint.Presentation..........etc.)
Dim oDatasheet as Object
Dim lRowCnt as Long
Dim currDB as DAO.Database
Dim Rec_Set as DAO.Recordset
Dim CGFF_field as DAO.Field
Dim pptGraph as Graph.Chart
Dim intCnt as Integer
Dim intRecCnt as Integer
' Does a bunch of stuff to set up the chart tables
' Loop through all of th eslides for this report type.
For intSlideCnt = 1 to intNumSlides
intFieldCnt = 1
int ShpCnt = 0
' If need to start a new slide
If (intRecCnt = 0) and (lFowCnt<intNumRows) Then
' Add a new slide
Set objPPSlide = AddNewSlide(objPPPres, ppLayoutTitleOnly, strSlideTitle)
pptGraph.Application.Update
DoEvents
End If
'add the graph
Set pptGraph=objPPSlide.Shapes.AddOLEObject(Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight-50, ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
' More processing goes on here repeating the creation of slides several times. Now to get the scale on the slides all the same.
' If there were more than one slide for this report
if intNumSlides > 1 then
if pptGraph.Axes(xlValue).MaximumScale>intMaxScale then
intMaxScale=pptGraph.Axes(xlValue).MaximumScale
End If
Set pptGraph=Nothing
' Loop through all of the slides for this report and update the maximum scale
For intCnt=intStartSlideNum to intSlideNum
********This is the line that is failing********
Set pptGraph = objPPPres.Slides(intCnt).Shapes(2).OLEFormat.Object
With pptGraph
.Axes(xlValue).MaximumScale = intMaxScale
.Axes(xlValue).MinimumScale = 0
End With
Set pptGraph = Nothing
Next intCnt
End If
' More processing
End
Blame any typo's in the above code on me. It compiles just fine. I had to transcribe it by hand.
Any insight into why this procedure, which works fine in 2003 by the way, fails now would be helpful.
Thank you,
Paul