Excel charts to powerpoint vba?

You have to activate the sheet before you export the chart. I have faced this problem in the past when exporting the charts.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a standard code that prints all charts in your active sheet to a new powerpoint application: Sub CreatePowerPoint() 'First we declare the variables we will be using Dim newPowerPoint As PowerPoint. Application Dim activeSlide As PowerPoint. Slide Dim cht As Excel.

ChartObject 'Look for existing instance On Error Resume Next Set newPowerPoint = GetObject(, "PowerPoint. Application") On Error GoTo 0 'Let's create a new PowerPoint If newPowerPoint Is Nothing Then Set newPowerPoint = New PowerPoint. Application End If 'Make a presentation in PowerPoint If newPowerPoint.Presentations.

Count = 0 Then newPowerPoint.Presentations. Add End If 'Show the PowerPoint newPowerPoint. Visible = True 'Loop through each chart in the Excel worksheet and paste them into the PowerPoint For Each cht In ActiveSheet.

ChartObjects 'Add a new slide where we will paste the chart newPowerPoint. ActivePresentation.Slides. Add newPowerPoint.

ActivePresentation.Slides. Count + 1, ppLayoutText newPowerPoint.ActiveWindow.View. GotoSlide newPowerPoint.

ActivePresentation.Slides. Count Set activeSlide = newPowerPoint. ActivePresentation.

Slides(newPowerPoint. ActivePresentation.Slides. Count) 'Copy the chart and paste it into the PowerPoint as a Metafile Picture cht.

Select ActiveChart.ChartArea. Copy activeSlide.Shapes. PasteSpecial(DataType:=ppPasteMetafilePicture).

Select 'Set the title of the slide the same as the title of the chart activeSlide. Shapes(1).TextFrame.TextRange. Text = cht.Chart.ChartTitle.

Text 'Adjust the positioning of the Chart on Powerpoint Slide newPowerPoint.ActiveWindow.Selection.ShapeRange. Left = 15 newPowerPoint.ActiveWindow.Selection.ShapeRange. Top = 125 activeSlide.

Shapes(2). Width = 200 activeSlide. Shapes(2).

Left = 505 Next AppActivate ("Microsoft PowerPoint") Set activeSlide = Nothing Set newPowerPoint = Nothing End Sub What I need to do is change the instead of activesheet to whole workbook, so copy over all charts in workbook. I tried introducing what I use to read through the workbook and delete all sheets : Sub ClearCharts() Dim wsItem As Worksheet Dim chtObj As ChartObject For Each wsItem In ThisWorkbook. Worksheets For Each chtObj In wsItem.

ChartObjects chtObj. Delete Next Next End Sub but it runs and doesn't copy over the charts when I try and edit the activesheet line. Any ideas would be appreciated for me to progress.

Thankyou excel-vba link|improve this question edited Mar 23 at 18:09Siddharth Rout5,624219 asked Mar 23 at 14:07Zenaphor365 88% accept rate.

You have to activate the sheet before you export the chart. I have faced this problem in the past when exporting the charts. Try this Dim wsItem As Worksheet Dim chtObj As ChartObject For Each wsItem In ThisWorkbook.

Worksheets For Each chtObj In wsItem. ChartObjects wsItem. Activate '~~> Code here to copy it to the poerpoint '~~> Same for deleting it DoEvents Next Next.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions