I'm getting - Method 'InsideHeight' of object 'PlotArea' failed. I'm using Access Automation to build Powerpoint presentations and on a slide where I have 2 charts I'm lining up the 2 chart's plot areas so the data on each chart line up. The error does not happen every time I run the code. It appears to happen randomly. I tried putting a Doevents in the code in case there was a timing issue but that has not corrected it. Now once I get the error and the code breaks I do a next and sometimes it continues and other time I get the error again. If I continue to do Next eventually it continues (could be 3 or 4 times before it runs). Here is my code:
Public Sub Lineup_Charts(xChart1 As Powerpoint.Chart, xChart2 As Powerpoint.Chart)
On Error GoTo Lineup_Charts_Err
Dim sChart1Top As Single
Dim sChart2Top As Single
Dim sChart1Left As Single
Dim sChart2Left As Single
' xChart1 is the data Chart
' xChart2 is the norm Chart
'
DoEvents
xChart2.PlotArea.InsideHeight = xChart1.PlotArea.InsideHeight ' This is where it fails
xChart2.PlotArea.InsideWidth = xChart1.PlotArea.InsideWidth
'
sChart1Top = xChart1.Parent.TOP + xChart1.PlotArea.InsideTop + xChart1.ChartArea.TOP
sChart2Top = xChart2.Parent.TOP + xChart2.PlotArea.InsideTop + xChart2.ChartArea.TOP
If sChart1Top > sChart2Top Then
xChart2.Parent.TOP = xChart2.Parent.TOP + (sChart1Top - sChart2Top)
Else
If sChart1Top < sChart2Top Then
xChart2.Parent.TOP = xChart2.Parent.TOP - (sChart2Top - sChart1Top)
End If
End If
'
sChart1Left = xChart1.Parent.Left + xChart1.PlotArea.InsideLeft + xChart1.ChartArea.Left
sChart2Left = xChart2.Parent.Left + xChart2.PlotArea.InsideLeft + xChart1.ChartArea.Left
'
If sChart1Left > sChart2Left Then
xChart2.Parent.Left = xChart2.Parent.Left + (sChart1Left - sChart2Left)
Else
If sChart1Left < sChart2Left Then
xChart2.Parent.Left = xChart2.Parent.Left - (sChart2Left - sChart1Left)
End If
End If
'
Lineup_Charts_Exit:
Exit Sub
Lineup_Charts_Err:
gErrorProcedure = "Lineup_Charts"
DoCmd.OpenForm "GenericErrorForm"
Resume Lineup_Charts_Exit
End Sub
I saw a Post on another site where the author solved the problem in Excel. In that post the answer was turning on ScreenUpdating in Excel. Now as far as I know there isn't a setting for this in Powerpoint. Does anyone have any suggestions on how I could work around this issue? Thanks for the Help!