bergsorensen
New Member
- Joined
- Jul 4, 2014
- Messages
- 26
Hello Mr. Excel
Long term passive member, first post
I have a small VBA job i need coded (forgive my code-lacking skills, just recently started using VBA.. couple of days ago), stuck on the syntax.
What im trying todo is:
- From a list (array) pick each graph with the corrosponding name, and copy that graph (as a meta-picture) to a new slide in an PowerPoint Pres..
- I can create a new empty powerpoint object, but im having trouble with the "looping-through-each-graph-and-copy-to-new-slide" part.
Again, im not familiar with the VBA syntax, communicating with Powerpoint from excel.
Here is my humble code so far:
-------------------------------------------------------------------
'Options
Option Base 1
'Macro
Sub CopyChartsToPPT()
'Declare variables
'Excel
Dim arrGraphs() As String
Dim Graphtobeprinted As String
'PowerPoint
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.slide
'Array of graphs to be copied
i = 1 'start position
While ActiveWorkbook.Sheets("Controls").Cells(i, 1) <> vbNullString
x = x + 1
ReDim Preserve arrGraphs(x)
arrGraphs(x) = ActiveWorkbook.Sheets("Controls").Cells(i, 1)
i = i + 1
Wend
'Create powerpoint presentation object
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPres = pptApp.Presentations.Add
Set pptPres = pptApp.ActivePresentation
pptApp.ActiveWindow.ViewType = ppViewSlide
'Loop
For x = LBound(arrGraphs) To UBound(arrGraphs)
Graphtobeprinted = arrGraphs(x)
'Create new powerpoint dias 'HELP NEEDED FOR THIS SECTION
Set pptSld = pptPres.Slides.Add(x + 1, 12)
'Copy graph
'...
'Paste graph
'...
'Make center/size stuff.. "make it look pretty"
'...
Next
MsgBox ("Done Total of " & i - 1 & " graphs were copied to PowerPoint")
End Sub
Best
Kasper
Long term passive member, first post
I have a small VBA job i need coded (forgive my code-lacking skills, just recently started using VBA.. couple of days ago), stuck on the syntax.
What im trying todo is:
- From a list (array) pick each graph with the corrosponding name, and copy that graph (as a meta-picture) to a new slide in an PowerPoint Pres..
- I can create a new empty powerpoint object, but im having trouble with the "looping-through-each-graph-and-copy-to-new-slide" part.
Again, im not familiar with the VBA syntax, communicating with Powerpoint from excel.
Here is my humble code so far:
-------------------------------------------------------------------
'Options
Option Base 1
'Macro
Sub CopyChartsToPPT()
'Declare variables
'Excel
Dim arrGraphs() As String
Dim Graphtobeprinted As String
'PowerPoint
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.slide
'Array of graphs to be copied
i = 1 'start position
While ActiveWorkbook.Sheets("Controls").Cells(i, 1) <> vbNullString
x = x + 1
ReDim Preserve arrGraphs(x)
arrGraphs(x) = ActiveWorkbook.Sheets("Controls").Cells(i, 1)
i = i + 1
Wend
'Create powerpoint presentation object
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPres = pptApp.Presentations.Add
Set pptPres = pptApp.ActivePresentation
pptApp.ActiveWindow.ViewType = ppViewSlide
'Loop
For x = LBound(arrGraphs) To UBound(arrGraphs)
Graphtobeprinted = arrGraphs(x)
'Create new powerpoint dias 'HELP NEEDED FOR THIS SECTION
Set pptSld = pptPres.Slides.Add(x + 1, 12)
'Copy graph
'...
'Paste graph
'...
'Make center/size stuff.. "make it look pretty"
'...
Next
MsgBox ("Done Total of " & i - 1 & " graphs were copied to PowerPoint")
End Sub
Best
Kasper
Last edited: