Resize chart in ppt

I have a VBA macro in ppt that takes data from an outside excel Spreadsheet and pastes it into a chart data spreadsheet in PPT and creates a chart in PPT. I have everything setup but I need to resize a chart so it will fit the whole slide. Is there a way to do that in PPT VBA? I have pasted my code below. Any help would be greatly appreciated.

Public dlgOpen As FileDialog
Public folder As String
Public excelApp As Object
Public xlWorkbook As Excel.Workbook
Public xlWorkBook2 As Excel.Workbook
Public GTChartData As Excel.Workbook
Public PPT As Presentation
Public xlws As Excel.Worksheet
Public xlws2 As Excel.Worksheet
Public GenTotalsChart As Chart

Public Sub GenerateVisual()

Set dlgOpen = Application.FileDialog(Type:=msoFileDialogFolderPicker)

    dlgOpen.Show
    dlgOpen.Title = "Select Report Location"

    folder = dlgOpen.SelectedItems(1)

    Set PPT = ActivePresentation
    Set excelApp = CreateObject("Excel.Application")

    excelApp.Visible = True

Set xlWorkbook = excelApp.workbooks.Open(folder & "\MarketSegmentTotals.xls")
Set xlws = xlWorkbook.Sheets("MarketSegmentTotals")
Set xlWorkBook2 = excelApp.workbooks.Open(folder & "\GeneralTotals.xls")
Set xlws2 = xlWorkBook2.Sheets("Totals")
Set GenTotalsChart = ActivePresentation.Slides(1).Shapes.AddChart.Chart
Set GTChartData = GenTotalsChart.ChartData.Workbook

With GTChartData.ActiveSheet

  .Range("B1").Value = xlws.Range("A1").Value
  .Range("C1").Value = xlws.Range("B1").Value
  .Range("D1").Value = xlws.Range("C1").Value
  .Range("E1").Value = xlws.Range("D1").Value
  .Range("F1").Value = xlws.Range("E1").Value
  .Range("G1").Value = xlws.Range("F1").Value

  .Range("B2").Value = xlws.Range("A2").Value
  .Range("C2").Value = xlws.Range("B2").Value
  .Range("D2").Value = xlws.Range("C2").Value
  .Range("E2").Value = xlws.Range("D2").Value
  .Range("F2").Value = xlws.Range("E2").Value
  .Range("G2").Value = xlws.Range("F2").Value


End With

GTChartData.ActiveSheet.ListObjects("Table1").Resize Range("$A$1:$G$2")
GTChartData.ActiveSheet.Range("A2").Clear

With GenTotalsChart
.HasTitle = True
.ChartTitle.Text = "DD Ready by Market Segment"
.HasDataTable = True
.ChartArea.Width = "848"
.ChartArea.Height = "448"
.DataTable.HasBorderHorizontal = False
.DataTable.HasBorderOutline = False
.DataTable.HasBorderVertical = False

End With

'MsgBox (GenTotalsChart.ChartArea.Width)
'MsgBox (GenTotalsChart.ChartArea.Height)







'excelApp.DisplayAlerts = False
'xlWorkbook.Close
'xlWorkBook2.Close
'Application.DisplayAlerts = True
'
'excelApp.Quit


End Sub

Answers


GenTotalsChart.Parent will give you a reference to the shape containing the chart, so:

With GenTotalsChart.Parent
   .Left = 0
   .Top = 0
   .Width = ActivePresentation.PageSetup.SlideWidth
   .Height = ActivePresentation.PageSetup.SlideHeight
End With

Need Your Help

Accessing custom property of lists of site definition in default.aspx page

c# sharepoint-2010 site-definition list-definition

I am working on Sharepoint. I am creating a site definition that is having a list using that I am insert so many properties inside the list. I am done with the creation part. Now I have to display ...