riniheijnen
New Member
- Joined
- Feb 8, 2012
- Messages
- 6
I have an excelsheet with a certain range "realusedrange" that has to be pasted in a Powerpint-slide. Because I want to give the user the possibility to make complete the range I made a commandbutton on the excelsheet. When the user presses this button another macro should be started where the pasting happens.
realusedrange.Copy
Cells(lastrow + 2, 3).Select
With Selection
ActiveSheet.buttons.Add(ActiveCell.Left, ActiveCell.Top, 120,60).Select
Selection.OnAction = "PERSONAL.XLSB!macro_powerpoint_slide()"
Selection.Characters.Text = "Powerpoint" & vbCrLf & "Presentatie"
With Selection.Characters(Start:=1, Length:=23).Font
.Name = "Calibri"
.FontStyle = "Standaard"
.Size = 16
End With
End With
Sub macro_powerpoint_slide()
Dim pptApp As PowerPoint.Application
Dim pptPrs As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptshp As PowerPoint.Shape
Set pptApp = CreateObject("Powerpoint.application")
pptApp.Visible = True
Set pptPrs = pptApp.Presentations.Open("C:\VVVierpolders\automation\Templates\TV-sponsors template." & "potx")
Set pptSld = pptPrs.Slides(1)
Set pptshp = pptSld.Shapes(1)
'plakken excel-tabel in powerpoint slide
pptSld.Shapes.PasteSpecial(ppPasteOLEObject).Select
End Sub
When I run the code I'll get an error
"unable to set the onaction property of the button class"
When I put the text of the second macro at the end of the first macro it works ok for me.
I guess I have to pass "realusedrange"tot the macro "macro_powerpoint_slide()" but I don't know how.
Anyone has any suggesions?
realusedrange.Copy
Cells(lastrow + 2, 3).Select
With Selection
ActiveSheet.buttons.Add(ActiveCell.Left, ActiveCell.Top, 120,60).Select
Selection.OnAction = "PERSONAL.XLSB!macro_powerpoint_slide()"
Selection.Characters.Text = "Powerpoint" & vbCrLf & "Presentatie"
With Selection.Characters(Start:=1, Length:=23).Font
.Name = "Calibri"
.FontStyle = "Standaard"
.Size = 16
End With
End With
Sub macro_powerpoint_slide()
Dim pptApp As PowerPoint.Application
Dim pptPrs As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptshp As PowerPoint.Shape
Set pptApp = CreateObject("Powerpoint.application")
pptApp.Visible = True
Set pptPrs = pptApp.Presentations.Open("C:\VVVierpolders\automation\Templates\TV-sponsors template." & "potx")
Set pptSld = pptPrs.Slides(1)
Set pptshp = pptSld.Shapes(1)
'plakken excel-tabel in powerpoint slide
pptSld.Shapes.PasteSpecial(ppPasteOLEObject).Select
End Sub
When I run the code I'll get an error
"unable to set the onaction property of the button class"
When I put the text of the second macro at the end of the first macro it works ok for me.
I guess I have to pass "realusedrange"tot the macro "macro_powerpoint_slide()" but I don't know how.
Anyone has any suggesions?
Code: